UIButton as in UIActionSheet
I would like to put a UIButton in my UIViewController with a style like buttons in the UIActionSheet. What should I add here:
UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
[ button setFrame: CGRectMake(10, 10, 50, 35) ];
[button setTitle:@"Button from UIActionSheet" forState: UIControlStateNormal];
[self addSubview: button];
+2
user188048
source
to share
4 answers
You need to get the background image from somewhere and then set it using: - (void)setBackgroundImage:(UIImage *)image forState:(UIControlState)state
I believe the .psd linked here has an action button background image http://media.photobucket.com/image/uiactionsheet%20button%20psd/visionwidget/iphone-gui-psd-file.jpg
+2
source to share
you can use segmented control - very nice trick
segmented = [[[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"Info",@"Configuration", nil]] autorelease];
[segmented addTarget:self action:@selector(changeView:) forControlEvents:UIControlEventValueChanged];
segmented.tintColor = [UIColor colorWithRed:0.20 green:0.20 blue:0.52 alpha:1.0];
segmented.segmentedControlStyle = UISegmentedControlStyleBar;
+1
source to share