您的位置:首页 > 移动开发 > IOS开发

iOS开发-修改TableViewCell的Delete按钮

2016-01-27 12:18 309 查看
自定义一个TableViewCell控件在layoutSubviews方法中重载一下按钮
- (void)layoutSubviews

{

    [super
layoutSubviews];

   
for (UIView
* view
in
self.subviews) {

       
if ([NSStringFromClass([view
class])
isEqualToString:@"UITableViewCellDeleteConfirmationView"])
{

           
UIButton * button = [UIButton
buttonWithType:UIButtonTypeCustom];

            [button
setBackgroundImage:[UIImage
imageNamed:@"盒子_好友_14"]
forState:UIControlStateNormal];

            [button
setBackgroundImage:[UIImage
imageNamed:@"盒子_好友_14"]
forState:UIControlStateHighlighted];

            [button
setBackgroundImage:[UIImage
imageNamed:@"盒子_好友_14"]
forState:UIControlStateSelected];

            [button
setFrame:CGRectMake(0,
0,
100,
100)];

            [button
addTarget:self
action:@selector(buttonClick:)
forControlEvents:UIControlEventTouchUpInside];

            [(UIView
*)[view.subviews
firstObject]
addSubview:button];

            ((UIView
*)[view.subviews
firstObject]).backgroundColor
= [UIColor
whiteColor];

        }

    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios开发 ui 控件