现在的位置: 首页 > 综合 > 正文

定制UIActionSheet

2013年09月01日 ⁄ 综合 ⁄ 共 622字 ⁄ 字号 评论关闭
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
    if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) {
        for (UIView *view in actionSheet.subviews) {
            if (view.tag == 2) {
                UIButton *button = (UIButton *) view;
                //改变背景
                [button setBackgroundImage:[button backgroundImageForState:UIControlStateHighlighted] forState:UIControlStateNormal];
                //改变颜色
                [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                //btn的选择状态,否则选择后不变背景
                [button setSelected:YES];
            } else {
            }
        }
 
    } else {
        //IOS4之前版本下按钮不是继承于UIButton而是UIThreePartButton
        for (UIView *view in actionSheet.subviews) {
            if (view.tag == 2) {
                UIControl *btn = (UIControl *) view;
                [btn setSelected:YES];
            } else {
            }
        }
    } 
}

抱歉!评论已关闭.