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


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


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


Maybe there is some simple way, for example, to set some property?

0


source


Here is a post about using Apple's private UIGlassButton class.

You can't submit an app to the App Store, but you can grab the generated wallpaper for reuse in published apps.

0


source







All Articles