圆点view被切掉一块的bug
2017-08-10 10:07
441 查看
需要实现有新消息提醒时在title的右上角有红点提示,一个本来很简单的功能,但是遇到一个很奇葩的问题,有一个红点在6、6p上显示,红点的右边会有一点点被切平了,但是其他的几个红点是好的。真是一个很无语的bug啊
FUCK YOU MONEY
然后我就只能去跟这个bug,看看在3d视图显示上是啥样的,看了后发现,哈,真圆,圆的不能再圆了。
这里是模拟器上的图片,是没有问题的。真机上才会有。
此处略去找问题的艰辛…(10000字)
最后经过我的不懈努力,终于找到问题解决的办法
在设置红点的center的时候取整一下,就解决了
想想原因应该是苹果本身屏幕分辨率的问题
以后再遇到这类问题也算是有一个解决方案了
下面是自定义的一个公共类视图
FUCK YOU MONEY
然后我就只能去跟这个bug,看看在3d视图显示上是啥样的,看了后发现,哈,真圆,圆的不能再圆了。
这里是模拟器上的图片,是没有问题的。真机上才会有。
此处略去找问题的艰辛…(10000字)
最后经过我的不懈努力,终于找到问题解决的办法
button.redDotView.center = CGPointMake(nearbyint(CGRectGetMaxX(button.titleLabel.frame)), CONTENT_PIXEL(65));
在设置红点的center的时候取整一下,就解决了
想想原因应该是苹果本身屏幕分辨率的问题
以后再遇到这类问题也算是有一个解决方案了
下面是自定义的一个公共类视图
#import "CETCHomeButton.h" @implementation CETCHomeButton - (void)setSelected:(BOOL)selected{ [super setSelected:selected]; if (selected) { self.backgroundColor = [UIColor groupTableViewBackgroundColor]; }else{ self.backgroundColor = [UIColor whiteColor]; } } - (void)setHighlighted:(BOOL)highlighted{ [super setHighlighted:highlighted]; [self setSelected:highlighted]; } - (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; } return self; } - (UIImageView *)imageView{ if (!_imageView) { _imageView = [[UIImageView alloc]init]; _imageView.contentMode = UIViewContentModeScaleAspectFit; [self addSubview:_imageView]; } return _imageView; } - (UIImageView *)bgImageView{ if (!_bgImageView) { _bgImageView = [[UIImageView allo b7c0 c]init]; [_bgImageView sendSubviewToBack:self]; [self addSubview:_bgImageView]; } return _bgImageView; } - (UILabel *)titleLabel{ if (!_titleLabel) { _titleLabel = [[UILabel alloc]init]; _titleLabel.textColor = CETC_GRAY_COLOR; _titleLabel.font = FONT_WITH_SIZE(15); _titleLabel.textAlignment = NSTextAlignmentCenter; [self addSubview:_titleLabel]; } return _titleLabel; } - (UILabel *)detailLabel{ if (!_detailLabel) { _detailLabel = [[UILabel alloc]init]; _detailLabel.textColor = CETC_LIGHT_GRAY_COLOR; _detailLabel.font = FONT_WITH_SIZE(CONTENT_PIXEL(7)); _detailLabel.textAlignment = NSTextAlignmentCenter; [self addSubview:_detailLabel]; } return _detailLabel; } - (UIView *)redDotView{ if (!_redDotView) { _redDotView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 8, 8)]; // _redDotView.layer.masksToBounds = YES; _redDotView.layer.cornerRadius = 4.f; _redDotView.backgroundColor = CETC_RED_COLOR; [self bringSubviewToFront:_redDotView]; [self addSubview:_redDotView]; } return _redDotView; } 下面是调用的 for (NSInteger i = 0; i < buttonList.count; i ++) { CETCHomeButton *button = [[CETCHomeButton alloc]initWithFrame:CGRectMake((buttonW + 1)* i, 0, buttonW, cellHeight)]; button.tag = 101 + i; [button addTarget:self action:@selector(buttonsAction:) forControlEvents:UIControlEventTouchUpInside]; [self.contentView addSubview:button]; button.imageView.frame = CGRectMake(buttonW/2 - CONTENT_PIXEL(17), CONTENT_PIXEL(20), CONTENT_PIXEL(34), CONTENT_PIXEL(34)); button.titleLabel.frame = CGRectMake(0, CONTENT_PIXEL(65), buttonW, CONTENT_PIXEL(15)); button.detailLabel.frame = CGRectMake(0, CONTENT_PIXEL(85), buttonW, CONTENT_PIXEL(15)); button.detailLabel.font = FONT_WITH_SIZE(CONTENT_PIXEL(9)); button.detailLabel.adjustsFontSizeToFitWidth = YES; button.titleLabel.font = FONT_WITH_SIZE(CONTENT_PIXEL(15)); NSDictionary *buttonDict = buttonList[i]; button.imageView.image = [UIImage imageNamed:buttonDict[@"image"]]; button.titleLabel.text = buttonDict[@"title"]; button.detailLabel.text = buttonDict[@"detail"]; [button.titleLabel sizeToFit]; button.titleLabel.centerX = buttonW/2; button.redDotView.center = CGPointMake(nearbyint(CGRectGetMaxX(button.titleLabel.frame)), CONTENT_PIXEL(65)); button.redDotView.hidden = YES; }
相关文章推荐
- android中属性动画的bug,以及ViewCompat
- 自定义控件 - ViewPager页面指示器,轮播小圆点效果,具有三种风格
- 一个关于 UIPickerView 的 bug
- 快速切换界面让tableview频繁下拉刷新导致界面上移54px的bug
- (自定义MyBanner)小圆点设置,及viewpager图片轮播
- 使用RecyclerView实现QQ空间广告位一个位置两个图时偶遇bug
- Asp.net 小技巧 1 :解决__VIEWSTATE bug
- 解决iOS中UICollectionViewCell点击无反应,长按才能选中的bug
- Android中ViewPager的简单使用(底部圆点)
- 简单的ViewPager+Fragment+小圆点的实现
- 成功解决RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid item position
- [Android]最省内存的ViewPager添加小圆点指示器
- cocos2d-x CCTableView动态插入删除元素bug修正及动画表现
- Viewpager 自动轮播(无限循环) ,手动滑动时停止轮播+底部小圆点(一)
- 解决Android SwipeRefreshLayout & RecyclerView使用的Bug
- ViewPager自动轮播,自定义小圆点的改变
- this class is not key value coding-compliant for the key countryImageView-bug
- 【Android】自定义带进度条的WebView,修复不弹出软键盘的BUG
- 【知识整理】惊现RecyclerView内部Bug???别急,我们慢慢解决它~
- ngui scrowview bug --- 动态向grid里添加项后没有自动裁剪Cliping