Change UIPickerView background

You could also mask the component. With a bit fiddeling you can get the size of the component and cut it out with following code: CALayer* mask = [[CALayer alloc] init]; [mask setBackgroundColor: [UIColor blackColor].CGColor]; [mask setFrame: CGRectMake(10.0f, 10.0f, 260.0f, 196.0f)]; [mask setCornerRadius: 5.0f]; [picker.layer setMask: mask]; [mask release]; Don’t forget #import <QuartzCore/QuartzCore.h>

Fixed labels in the selection bar of a UIPickerView

Create your picker, create a label with a shadow, and push it to a picker’s subview below the selectionIndicator view. It would look something like this UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(135, 93, 80, 30)] autorelease]; label.text = @”Label”; label.font = [UIFont boldSystemFontOfSize:20]; label.backgroundColor = [UIColor clearColor]; label.shadowColor = [UIColor whiteColor]; label.shadowOffset = CGSizeMake (0,1); … Read more

UIDatePicker select Month and Year

Here is a solution to get the same effect. For using this snippet of code you should replace UIPickerView to CDatePickerViewEx in nib file in “Custom class” of “Indentity inspector”. .h file #import <UIKit/UIKit.h> @interface CDatePickerViewEx : UIPickerView <UIPickerViewDelegate, UIPickerViewDataSource> @property (nonatomic, strong, readonly) NSDate *date; -(void)selectToday; @end .m file #import “CDatePickerViewEx.h” // Identifiers of … Read more

How to change UIPickerView height

It seems obvious that Apple doesn’t particularly invite mucking with the default height of the UIPickerView, but I have found that you can achieve a change in the height of the view by taking complete control and passing a desired frame size at creation time, e.g: smallerPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 120.0)]; You … Read more

Add UIPickerView & a Button in Action sheet – How?

One more solution: no toolbar but a segmented control (eyecandy) UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil]; [actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent]; CGRect pickerFrame = CGRectMake(0, 40, 0, 0); UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame]; pickerView.showsSelectionIndicator = YES; pickerView.dataSource = self; pickerView.delegate = self; [actionSheet addSubview:pickerView]; [pickerView release]; UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@”Close”]]; … Read more

altering font size and style in PickerView sections [closed]

You get the fonts using this loop: NSMutableArray *fontNames = [NSMutableArray array]; for(NSString *familyName in [UIFont familyNames]) { for(NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) { [fontNames addObject:fontName]; } } How you present the picker depends on your UI layout. You might use an UITableView in an UIPopoverController (just google it, you’ll find TONS of quite good … Read more

Swift – how to read data from many UITextFields which generate data by UIPickerView [closed]

You can set a pickerView as the textField.inputView. The example below is for two text fields sharing a single picker view, but you can extend it easily by checking the identity of the activeTextField in the picker view delegate methods. import UIKit class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { @IBOutlet weak var myTextFieldOne: UITextField! @IBOutlet weak … Read more