【发布时间】:2014-08-06 08:09:40
【问题描述】:
我正在使用自动布局,并且我有一个 RoundView 类(UIButton 的子视图),它的 drawRect 方法是:
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat lineWidth = 0.0;
CGContextSetLineWidth(context, lineWidth);
CGContextSetFillColorWithColor(context, _currentBackgroundColor.CGColor);
CGContextAddEllipseInRect(context, self.bounds);
CGContextFillPath(context);
}
然后我将它添加到 self(一个 UIView),使用自动布局设置它的宽度和高度。一切看起来都很棒。 但是当我改变它的大小限制(有一个更大的视图),并调用
[self layoutIfNeeded];
在动画块中,圆形像素看起来更大更丑。
我这样做是否正确?
【问题讨论】:
标签: ios core-graphics autolayout uiviewanimation drawrect