iOS UITableViewCell 改变系统选中按钮(UITableViewCellEditControl)的默认图片和位置
2017-06-02 10:34
681 查看
系统效果:
1.只改变蓝色底色,可以// cell.tintColor = [UIColor redColor];
2.改变图片和位置,
- (void)setEditing:(BOOL)editing animated:(BOOL)animated{
[super setEditing:editing animated:animated];
for (UIControl *control in self.subviews){
if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
for (UIView *v in control.subviews){
if ([v isKindOfClass: [UIImageView class]]) {
UIImageView *img=(UIImageView *)v;
// img.frame = CGRectMake(img.frame.origin.x, CountHeight(20), img.frame.size.width, img.frame.size.height);
img.center = CGPointMake(img.center.x, img.frame.size.height+5);
if (!self.selected) {
img.image=[UIImage imageNamed:@"weixuanzhongimg.png"];
}
}
}
}
}
}
-(void)layoutSubviews{
NSLog(@"%@",self.subviews);
for (UIControl *control in self.subviews){
if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
for (UIView *v in control.subviews){
if ([v isKindOfClass: [UIImageView class]]) {
UIImageView *img=(UIImageView *)v;
img.center = CGPointMake(img.center.x, img.frame.size.height+5);
// img.frame = CGRectMake(img.frame.origin.x, CountHeight(20), img.frame.size.width, img.frame.size.height);
if (self.selected) {
img.image=[UIImage imageNamed:@"xuanzhongimg.png"];
}else{
img.image=[UIImage imageNamed:@"weixuzhongimg.png"];
}
}
}
}
}
[super layoutSubviews];
}
效果
1.只改变蓝色底色,可以// cell.tintColor = [UIColor redColor];
2.改变图片和位置,
- (void)setEditing:(BOOL)editing animated:(BOOL)animated{
[super setEditing:editing animated:animated];
for (UIControl *control in self.subviews){
if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
for (UIView *v in control.subviews){
if ([v isKindOfClass: [UIImageView class]]) {
UIImageView *img=(UIImageView *)v;
// img.frame = CGRectMake(img.frame.origin.x, CountHeight(20), img.frame.size.width, img.frame.size.height);
img.center = CGPointMake(img.center.x, img.frame.size.height+5);
if (!self.selected) {
img.image=[UIImage imageNamed:@"weixuanzhongimg.png"];
}
}
}
}
}
}
-(void)layoutSubviews{
NSLog(@"%@",self.subviews);
for (UIControl *control in self.subviews){
if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
for (UIView *v in control.subviews){
if ([v isKindOfClass: [UIImageView class]]) {
UIImageView *img=(UIImageView *)v;
img.center = CGPointMake(img.center.x, img.frame.size.height+5);
// img.frame = CGRectMake(img.frame.origin.x, CountHeight(20), img.frame.size.width, img.frame.size.height);
if (self.selected) {
img.image=[UIImage imageNamed:@"xuanzhongimg.png"];
}else{
img.image=[UIImage imageNamed:@"weixuzhongimg.png"];
}
}
}
}
}
[super layoutSubviews];
}
效果
相关文章推荐
- iOS自定制tabbar与系统的tabbar冲突,造成第一次点击各个item图片更换选中,第二次选中部分item图片不改变
- UITableViewCell 自定义默认选中 和 改变cell背景图片
- iOS 之点击按钮改变状态的图片
- ios改变系统默认样式
- [iOS]iOS7+ UITabBar修改选中图片显示为默认蓝色的问题解决方法,去除UITabbar顶部一像素横线
- iOS -点击按钮查看大图,再次点击还原效果(此处以UITableViewCell为父视图,其中加载多个图片为例)
- iOS心得7 按钮的图片和文字自定义位置
- iOS 之点击按钮改变状态的图片
- 自定义导航栏的返回按钮,扩大点击区域,不改变图片的尺寸比例,同时可设置title和image的位置关系
- iOS开发-调整按钮的图片文字位置
- android 下改变默认的checkbox的 选中 和被选中 图片
- 仿新浪微博IOS客户端(v5.2.8)——自定义UITabBar替换系统默认的(添加“+”号按钮),
- 改变系统默认字体库的存储位置
- android actionBar searview改变默认搜索按钮图片
- iOS tabBar颜色渲染和改变选中时图片
- android 下改变默认的checkbox的 选中 和被选中 图片
- android 下改变默认的checkbox的 选中 和被选中 图片
- Linux系统入门学习:改变libvirt VM镜像的默认位置
- Linux系统入门学习:改变libvirt VM镜像的默认位置
- iOS小技巧-UISwitch改变系统默认的颜色