如何自定义uiactionsheet ios9中的内容

主题 : 自定义UIActionSheet,ios8无效了
级别: 骑士
可可豆: 1690 CB
威望: 1690 点
在线时间: 522(时)
发自: Web Page
来源于&&分类
自定义UIActionSheet,ios8无效了&&&
ios8下面,自定义UIActionSheet的无效了,大家有啥好的思路吗?又兼容ios8以下,ios8也能正常使用
级别: 骑士
可可豆: 1690 CB
威望: 1690 点
在线时间: 522(时)
发自: Web Page
级别: 精灵王
UID: 40471
可可豆: 3550 CB
威望: 3531 点
在线时间: 711(时)
发自: Web Page
UIActionSheet is deprecated in iOS 8. (Note that UIActionSheetDelegate is also deprecated.)
级别: 新手上路
可可豆: 3 CB
威望: 3 点
在线时间: 188(时)
发自: Web Page
(void)alertWithPicer:(UIPickerView *)picker{&&&&UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& message:@&\n\n\n\n\n\n\n\n\n\n\n&// change UIAlertController height&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&preferredStyle:UIAlertControllerStyleActionSheet];&&&&&&&&//Make a frame for the picker & then create the picker&&&&CGRect pickerFrame = CGRectMake(12, 12, 270, 250);&&&&picker.frame = pickerF&&&&ios8Picker =&&&&NSLog(@&%ld&,(long)ios8Picker.tag);&&&&&&&&&&&&//set the pickers selection indicator to true so that the user will now which one that they are chosing&&&&[picker setShowsSelectionIndicator:YES];&&&&&&&&//Add the picker to the alert controller&&&&[alert.view addSubview:picker];&&&&&&&&//make the toolbar view&&&& UIToolbar *toolView = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, alert.view.frame.size.width-16, kToolBarHeight)];&&&&toolView.backgroundColor = [UIColor blackColor]; //set it's background&&&&toolView.barStyle = UIBarStyleBlackT&&&&&&&&UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, kToolBarHeight)];&&&&titleLabel.backgroundColor = [UIColor clearColor];&&&&titleLabel.font = [UIFont systemFontOfSize:14];&&&&titleLabel.textColor = [UIColor whiteColor];&&&&titleLabel.textAlignment = NSTextAlignmentC&&&&//&&&&titleLabel.text =&&&&UIBarButtonItem *bbtTitle = [[UIBarButtonItem alloc] initWithCustomView:titleLabel];&&&&UIBarButtonItem *bbtSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];&&&&UIBarButtonItem *bbtOK = [[UIBarButtonItem alloc] initWithTitle:@&确定& style:UIBarButtonItemStyleDone target:self action:@selector(OKWithPicker)];&&&&bbtOK.width = 60.f;&&&&UIBarButtonItem *bbtCancel = [[UIBarButtonItem alloc] initWithTitle:@&取消& style:UIBarButtonItemStylePlain target:self action:@selector(CancleWithPicker)];&&&&bbtCancel.width = 60.f;&&&&toolView.items = [NSArray arrayWithObjects:bbtCancel,bbtSpace,bbtTitle,bbtSpace,bbtOK, nil];&&&&&&&&[alert.view addSubview:toolView];&&&&&&&&[self presentViewController:alert animated:NO completion:nil];}里面注释写的很详细,我里面写的东西可以无视。可以换成别的subview,\n\n可以控制uialertcontroller高度
级别: 侠客
UID: 279612
可可豆: 307 CB
威望: 387 点
在线时间: 438(时)
发自: Web Page
自定义一个view像actionsheet一样
级别: 骑士
可可豆: 1690 CB
威望: 1690 点
在线时间: 522(时)
发自: Web Page
回 4楼(过去式) 的帖子
自定义view了,省得还因为ios6和ios7的背景颜色不同,用不同的icon
级别: 新手上路
UID: 154537
可可豆: 149 CB
威望: 107 点
在线时间: 120(时)
发自: Web Page
同问楼主是中么解决的
关注本帖(如果有新回复会站内信通知您)
iPhone5的分辨率? 正确答案:
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版&&&&IOS自定义UIActionSheet的Demo
IOS自定义UIActionSheet的Demo
IOS自定义UIActionSheet的例子,供大家学习
若举报审核通过,可奖励20下载分
被举报人:
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:
您可能还需要
移动开发下载排行收藏,5.6k 浏览
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
iPhone应用能不能自定义UIActionSheet的样式,默认的那个黑了吧唧太丑了
我看有些应用类似的UIActionSheet很漂亮,他们这种是完全自己实现的,还是框架有什么接口可以调用的?
类似这种:
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
用一个黑色的底做透明度渐变动画,同时底部放按钮的视图做位移动画就可以了。
另外我建议楼主把翻页控件的贴结了~.h:#import &UIKit/UIKit.h&
@class YXPActionS
@protocol YXPActionSheetDelegate &NSObject&
- (void)actionSheet:(YXPActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex buttonTitle:(NSString *)
@interface YXPActionSheet : UIView
+ (YXPActionSheet *)actionSheetWithCancelButtonTitle:(NSString *)cancelTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(id)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
@property (nonatomic,assign) id&YXPActionSheetDelegate&
- (void)showInView:(UIView *)
- (void)showInW
- (void)showInViewFromLeft:(UIView *)
- (void)showInWindowFromL
YXPSheetView.m
YXPiOSClient
Created by openthread on 7/27/12.
Copyright (c) 2012 __MyCompanyName__. All rights reserved.
#import &YXPActionSheet.h&
#define BUTTON_LABEL_TAG 891204
@interface YXPActionSheet()
+ (UILabel *)buttonLabelWithText:(NSString *)
- (void)setActionSheetHeight:(CGFloat)
- (void)addButton:(UIButton *)
- (void)resizeB
- (void)buttonTouched:(UIButton *)
@implementation YXPActionSheet
UIView *_dimmV
UIImageView *_sheetBackgroundV
NSMutableArray *_buttonA
@synthesize delegate = _
+ (YXPActionSheet *)actionSheetWithCancelButtonTitle:(NSString *)cancelTitle
destructiveButtonTitle:(NSString *)destructiveButtonTitle
otherButtonTitles:(id)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION
YXPActionSheet *sheetView = [[YXPActionSheet alloc] initWithFrame:CGRectZero];
if(!sheetView)
NSUInteger buttonIndex = 0;
CGFloat height = 27.0f;
if (destructiveButtonTitle)
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tag = buttonIndex++;
button.frame = CGRectMake(0, height - 4.0f, 0.0f, 45.0f);
[button setBackgroundImage:[[UIImage imageNamed:@&YXPActionSheetDestructiveButton.png&] stretchableImageWithLeftCapWidth:22 topCapHeight:22] forState:UIControlStateNormal];
UILabel *label = [YXPActionSheet buttonLabelWithText:destructiveButtonTitle];
[button addSubview:label];
[sheetView addButton:button];
height += 59.0f;
va_start(args, otherButtonTitles);
for (NSString *arg = otherButtonT arg != arg = va_arg(args, NSString*))
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tag = buttonIndex++;
button.frame = CGRectMake(0, height - 4.0f, 0.0f, 45.0f);
[button setBackgroundImage:[[UIImage imageNamed:@&YXPActionSheetButton.png&] stretchableImageWithLeftCapWidth:22 topCapHeight:22] forState:UIControlStateNormal];
UILabel *label = [YXPActionSheet buttonLabelWithText:arg];
[button addSubview:label];
[sheetView addButton:button];
height += 59.0f;
va_end(args);
if (cancelTitle)
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tag = buttonIndex++;
button.frame = CGRectMake(0, height - 4.0f, 0.0f, 45.0f);
[button setBackgroundImage:[[UIImage imageNamed:@&YXPActionSheetCancelButton.png&] stretchableImageWithLeftCapWidth:22 topCapHeight:22] forState:UIControlStateNormal];
UILabel *label = [YXPActionSheet buttonLabelWithText:cancelTitle];
[button addSubview:label];
[sheetView addButton:button];
height += 59.0f;
[sheetView setActionSheetHeight:height];
return sheetV
- (id)initWithFrame:(CGRect)frame
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenRect.
self = [super initWithFrame:(CGRect){CGPointZero,screenSize}];
_buttonArray = [NSMutableArray array];
_dimmView = [[UIView alloc] initWithFrame:(CGRect){CGPointZero,screenSize}];
_dimmView.backgroundColor = [UIColor colorWithWhite:0.0f/255.0f alpha:0.5f];
[super addSubview:_dimmView];
_sheetBackgroundView = [[UIImageView alloc] initWithFrame:frame];
UIImage *backgroundImage = [UIImage imageNamed:@&YXPActionSheetBackground.png&];
backgroundImage = [backgroundImage stretchableImageWithLeftCapWidth:40 topCapHeight:40];
_sheetBackgroundView.userInteractionEnabled = YES;
_sheetBackgroundView.image = backgroundI
_sheetBackgroundView.userInteractionEnabled = YES;
[super addSubview:_sheetBackgroundView];
- (void)addSubview:(UIView *)view
[_sheetBackgroundView addSubview:view];
- (void)showInView:(UIView *)view
[view addSubview:self];
_sheetBackgroundView.transform = CGAffineTransformI
CGFloat height = _sheetBackgroundView.frame.size.
CGFloat superViewHeight = view.frame.size.
_dimmView.alpha = 0;
_sheetBackgroundView.frame = CGRectMake(0, superViewHeight, view.frame.size.width, height);
[self resizeButtons];
[UIView animateWithDuration:0.2 animations:^{
_dimmView.alpha = 1;
_sheetBackgroundView.frame = CGRectMake(0, superViewHeight - height, view.frame.size.width, height);
- (void)showInWindow
[self showInView:[[[UIApplication sharedApplication] delegate] window]];
- (void)showInViewFromLeft:(UIView *)view
[view addSubview:self];
CGFloat height = _sheetBackgroundView.frame.size.
CGFloat superViewHeight = view.frame.size.
_dimmView.alpha = 0;
CGRect originFrame = CGRectMake(-height / 2 - superViewHeight / 2,
superViewHeight / 2 - height / 2,
superViewHeight,
_sheetBackgroundView.frame = originF
_sheetBackgroundView.transform = CGAffineTransformMakeRotation(M_PI / 2);
[self resizeButtons];
[UIView animateWithDuration:0.2 animations:^{
_dimmView.alpha = 1;
_sheetBackgroundView.center = CGPointMake(height / 2, _sheetBackgroundView.center.y);
- (void)showInWindowFromLeft
[self showInViewFromLeft:[[[UIApplication sharedApplication] delegate] window]];
- (void)dismiss
[UIView animateWithDuration:0.2 animations:^{
_dimmView.alpha = 0;
if (CGAffineTransformEqualToTransform(_sheetBackgroundView.transform, CGAffineTransformMakeRotation(M_PI_2)))
CGFloat height = _sheetBackgroundView.frame.size.
CGFloat superViewHeight = self.superview.frame.size.
CGRect originFrame = CGRectMake(-height / 2 - superViewHeight / 2,
superViewHeight / 2 - height / 2,
superViewHeight,
_sheetBackgroundView.frame = originF
CGRect frame = _sheetBackgroundView.
frame.origin.y = self.superview.frame.size.
_sheetBackgroundView.frame =
} completion:^(BOOL finished) {
[self removeFromSuperview];
#pragma mark - Private Methods
+ (UILabel *)buttonLabelWithText:(NSString *)text
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 45)];
label.text =
label.font = [UIFont systemFontOfSize:19.0f];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor colorWithRed:44.0f/255.0f green:46.0f/255.0f blue:48.0f/255.0f alpha:1.0f];
label.shadowOffset = CGSizeMake(0, -1.0f);
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentC
label.text =
label.tag = BUTTON_LABEL_TAG;
- (void)resizeButtons
CGFloat frameWidth = _sheetBackgroundView.frame.size.
if (CGAffineTransformEqualToTransform(_sheetBackgroundView.transform, CGAffineTransformMakeRotation(M_PI_2)))
frameWidth =_sheetBackgroundView.frame.size.
for (UIView *eachButton in _buttonArray)
CGRect buttonFrame = eachButton.
buttonFrame.origin.x = 22;
buttonFrame.size.width = frameWidth - 44;
eachButton.frame = buttonF
UIView *label = [eachButton viewWithTag:BUTTON_LABEL_TAG];
label.frame = CGRectMake(10, 0, eachButton.frame.size.width - 20, eachButton.frame.size.height);
- (void)setActionSheetHeight:(CGFloat)height
_sheetBackgroundView.frame = CGRectMake(0, 0, 0, height);
- (void)addButton:(UIButton *)button
[_buttonArray addObject:button];
[button addTarget:self action:@selector(buttonTouched:) forControlEvents:UIControlEventTouchUpInside];
[_sheetBackgroundView addSubview:button];
- (void)buttonTouched:(UIButton *)button
if (self.delegate && [self.delegate respondsToSelector:@selector(actionSheet:clickedButtonAtIndex:buttonTitle:)])
UILabel *label = (UILabel *)[button viewWithTag:BUTTON_LABEL_TAG];
[self.delegate actionSheet:self clickedButtonAtIndex:button.tag buttonTitle:label.text];
[self dismiss];
@end八张切图YXPActionSheetDestructiveButton.png
YXPActionSheetDestructiveButton@2x.png
YXPActionSheetButton.png
YXPActionSheetButton@2x.png
YXPActionSheetCancelButton.png
YXPActionSheetCancelButton@2x.png
YXPActionSheetBackground.png
YXPActionSheetBackground@2x.png
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
自己实现,自定义个view,写一个delegate,showInView,hide方法。
- (void)showInView:(UIView *)v
[v addsubview:self];
//通过view动画将self.center上移。
hide时将[self removeFromSuperView].
delegate 中定义点击了哪个按钮,在实现delegate的viewcontroller中去实现就行。
同步到新浪微博
分享到微博?
与我们一起探索更多的未知
专业的开发者技术社区,为用户提供多样化的线上知识交流,丰富的线下活动及给力的工作机会
加入只需一步
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要举报该,理由是:
扫扫下载 App
SegmentFault
一起探索更多未知iOS 自定义UIActionSheet - 俺是一个瓜娃!!! - ITeye技术网站
博客分类:
一:模态视图
UIActionSheet、UIAlertView、GKPeerPickerController、UIAPopover、GKPanel等都是ios系统自带
的模态视图。
模态视图的一个重要的特性就是在显示模态视图的时候可以阻断其他视图的事件响应。
该特性在有些时候对我们是非常有用的。
那么任何自己实现一个模态视图呢?
一种方式就是自己实现一个UIViewController,然后作为一个modalViewController视图显示。这种方式固然可以
,但是需要的工作量可就不少了,例如显示动画,动态布局等等。
这里我要说的另一种方法,就是实现这些系统模态视图的子视图,对系统视图进行定制,以满足我们自己的需求。可以完美的使用系统模态
视图已经提供的动画、自动布局等等行为。
二:系统模态视图的显示方式
系统模态视图的显示和上面提到到的自定义模态视图的显示方式有很大的差别。
UIActionSheet、UIAlertView、GKPeerPickerController、UIAPopover、GKPanel 都是UIView的子类,
如果直接在读取视图之上显示这些UIActionSheet等等的视图,是无法阻断事件的。因此系统自带的这些模态
视图先被添加到一个UIWindow的视图,再把给window视图作为application的keyWindow显示。也就是在显示
模态视图的时候,application的多window的。
三:移除系统模态
调用dismiss系列的方法移除模态视图
四:模态视图的实现基础
所有的模态视图都基于UIViewControll提供的两个方法:
– presentModalViewController:animated:
– dismissModalViewControllerAnimated:
UIActionSheet、UIAlertView的实现都是对这两个方法的实现和在实现。
五:向模态视图添加其他UIView的方式:
一:动态添加UIView
(1):通过[UIApplication sharedApplication].keyWindow 取得当前的makeKeyAndVisible window,该window的
大小是这个屏幕的大小,和该window包含的 UIActionSheet等视图不是一个级别。UIActionSheet 仅仅是该window的
一个子视图而已。
[[UIApplication sharedApplication].keyWindow addSubview:self.progressHUD];
(2):根据读取模态视图的window属性,取得当前的makeKeyAndVisible window
[self.actionSheet.window addSubview:self.progressHUD]
注意:以上两种方式一定要在模态视图显示出来之后再添加其他的UIview,否则添加的UIView可能无法显示。
二:静态添加UIView
把需要添加的UIView视图直接在模态视图的drawRect方法中添加就可以了。这些在显示模态视图时候,添加的
UIView也会被显示处理。
UIActionSheet 视图的自定义
UserDetailVoiceCustomActionSheet.h
Created by xu on 12-12-15.
Copyright (c) 2012年 itotemstudio. All rights reserved.
#import &UIKit/UIKit.h&
@protocol BHCustomActionSheetDelegate &NSObject&
- (void)actionSheet:(UIActionSheet *)actionSheet clickedOtherButtonAtIndex:(NSInteger)buttonI
- (void)actionSheetCancel:(UIActionSheet *)actionS
- (void)actionSheetDestructive:(UIActionSheet *)actionS
@interface BHCustomActionSheet : UIActionSheet
*_destructiveB
id&BHCustomActionSheetDelegate& _customActionD
@property (nonatomic, retain) UIButton *destructiveB
@property (nonatomic, assign) id&BHCustomActionSheetDelegate& customActionD
UserDetailVoiceCustomActionSheet.m
Created by xu on 12-12-15.
Copyright (c) 2012年 itotemstudio. All rights reserved.
#import "BHCustomActionSheet.h"
#import "UIImageExt.h"
@interface BHCustomActionSheet ()
- (void)clickedOtherButton:(id)
- (void)clickCanncelB
- (void)clickDestructiveB
@implementation BHCustomActionSheet
@synthesize destructiveButton
= _destructiveB
@synthesize customActionDelegate = _customActionD
- (void)dealloc
_customActionDelegate =
RELEASE_SAFELY(_destructiveButton);
[super dealloc];
//去除背景色
- (void)drawRect:(CGRect)rect
UIImageView *bgView = [[[UIImageView alloc] initWithFrame:self.bounds] autorelease];
bgView.image = [[UIImage imageNamed:@"bg"] resizeUsingCapInsets:UIEdgeInsetsMake(180.f, 5.f, 4.f, 4.f)];
[self addSubview:bgView];
UILabel *titleLabel =
NSMutableArray *buttons = [NSMutableArray arrayWithCapacity:10];
for (UIView *view in self.subviews) {
if ([view isKindOfClass:[UIControl class]]) {
[self bringSubviewToFront:view];
[buttons addObject:view];
[view removeFromSuperview];
if ([view isKindOfClass:[UILabel class]]) {
titleLabel = (UILabel *)
if (titleLabel) {
CGRect hilghtBgImageFrame = CGRectMake(0.0f, 0.0f, CGRectGetWidth(rect), CGRectGetMaxY(titleLabel.frame) == 0.f?60.f:CGRectGetMaxY(titleLabel.frame) + 5.f);
UIImageView *hilghtBgImageView = [[[UIImageView alloc] initWithFrame:hilghtBgImageFrame] autorelease];
[self addSubview:hilghtBgImageView];
[self bringSubviewToFront:titleLabel];
hilghtBgImageView.image = [[UIImage imageNamed:@"bg-highlight"] resizeUsingCapInsets:UIEdgeInsetsMake(31.f, 5.f, 42.f, 4.f)];
NSMutableIndexSet *delSet = [NSMutableIndexSet indexSet];
if (self.destructiveButtonIndex &= 0) {
NSString *destructiveButtonTitle = [self buttonTitleAtIndex:self.destructiveButtonIndex];
UIButton *customDestructiveBut = [UIButton buttonWithType:UIButtonTypeCustom];
self.destructiveButton = customDestructiveB
[customDestructiveBut setTitleColor:[UIColor whiteColor]
forState:UIControlStateNormal];
[customDestructiveBut setTitleShadowColor:[UIColor whiteColor]
forState:UIControlStateNormal];
customDestructiveBut.titleLabel.font = [UIFont boldSystemFontOfSize:18.f];
[customDestructiveBut setBackgroundImage:[[UIImage imageNamed:@"but_Destructive"] resizeUsingCapInsets:UIEdgeInsetsMake(15.f, 50., 20.f, 60.f)]
forState:UIControlStateNormal];
[customDestructiveBut addTarget:self
action:@selector(clickDestructiveButton)
forControlEvents:UIControlEventTouchUpInside];
customDestructiveBut.frame = ((UIControl *)[buttons objectAtIndex:self.destructiveButtonIndex]).
[customDestructiveBut setTitle:destructiveButtonTitle forState:UIControlStateNormal];
[self addSubview:customDestructiveBut];
[delSet addIndex:self.destructiveButtonIndex];
if (self.cancelButtonIndex &= 0) {
NSString *cancelButtonTitle = [self buttonTitleAtIndex:self.cancelButtonIndex];
UIButton *customCancelBut = [UIButton buttonWithType:UIButtonTypeCustom];
[customCancelBut setTitleColor:[UIColor grayColor]
forState:UIControlStateNormal];
[customCancelBut setTitleShadowColor:[UIColor grayColor]
forState:UIControlStateNormal];
customCancelBut.titleLabel.font = [UIFont boldSystemFontOfSize:18.f];
[customCancelBut setBackgroundImage:[[UIImage imageNamed:@"but_Cancel"] resizeUsingCapInsets:UIEdgeInsetsMake(15.f, 50., 20.f, 60.f)]
forState:UIControlStateNormal];
[customCancelBut addTarget:self
action:@selector(clickCanncelButton)
forControlEvents:UIControlEventTouchUpInside];
customCancelBut.frame = ((UIControl *)[buttons objectAtIndex:self.cancelButtonIndex]).
[customCancelBut setTitle:cancelButtonTitle forState:UIControlStateNormal];
[self addSubview:customCancelBut];
[delSet addIndex:self.cancelButtonIndex];
[buttons removeObjectsAtIndexes:delSet];
int index = 0;
for (UIControl *control in buttons) {
NSString *otherButtonTitle = [self buttonTitleAtIndex:index];
UIButton *customOtherBut = [UIButton buttonWithType:UIButtonTypeCustom];
[customOtherBut setTitleColor:[UIColor grayColor]
forState:UIControlStateNormal];
[customOtherBut setTitleShadowColor:[UIColor grayColor]
forState:UIControlStateNormal];
customOtherBut.titleLabel.font = [UIFont boldSystemFontOfSize:18.f];
[customOtherBut setBackgroundImage:[[UIImage imageNamed:@"but_Cancel"] resizeUsingCapInsets:UIEdgeInsetsMake(15.f, 50., 20.f, 60.f)]
forState:UIControlStateNormal];
customOtherBut.tag =
[customOtherBut addTarget:self
action:@selector(clickedOtherButton:)
forControlEvents:UIControlEventTouchUpInside];
customOtherBut.frame = ((UIControl *)[buttons objectAtIndex:index]).
[customOtherBut setTitle:otherButtonTitle forState:UIControlStateNormal];
[self addSubview:customOtherBut];
[buttons removeAllObjects];
#pragma mark - Private Method
- (void)clickedOtherButton:(id)sender
NSInteger index = ((UIControl *)sender).
if (self.customActionDelegate
&& [self.customActionDelegate respondsToSelector:@selector(actionSheet:clickedButtonAtIndex:)]) {
[self.customActionDelegate actionSheet:self clickedOtherButtonAtIndex:index];
[self clickCanncelButton];
- (void)clickCanncelButton
if (self.customActionDelegate
&& [self.customActionDelegate respondsToSelector:@selector(actionSheetCancel:)]) {
[self.customActionDelegate actionSheetCancel:self];
[UIApplication sharedApplication].statusBarHidden = NO;
- (void)clickDestructiveButton
if (self.customActionDelegate
&& [self.customActionDelegate respondsToSelector:@selector(actionSheetDestructive:)]) {
[self.customActionDelegate actionSheetDestructive:self];
重新drawRect方法,可以去除UIActionSheet的默认样式,然后通过addSubView方法添加定制的视图。
浏览 12272
xiaozhao-521
浏览: 497774 次
来自: 天堂
擦,现在还行么,厉害
喜欢楼主分享问题的方式,有思想
赞楼主一个
标题写错了.

我要回帖

更多关于 uiactionsheet 颜色 的文章

 

随机推荐