自定义一个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 ];
}
}
{
[ 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 ];
}
}
}