相关疑难解决方法(0)

iOS 7上疯狂的圆角矩形UIBezierPath行为。如何处理?

下面的简单UIView绘制了一个圆角矩形。当我通过65或以下的拐角半径时,它会正确倒圆,但在66或以上时会产生一个完美的圆!这里发生了什么?仅当拐角半径等于框架宽度的1/2时,才应显示一个圆,但无论视图大小如何,似乎在半径约为1/3时都将绘制一个圆。此行为出现在iOS 7上。在iOS 6上,我得到了预期的行为。

#import "ViewController.h"
@interface MyView : UIView
@end

@implementation MyView
-(void)drawRect:(CGRect)rect {
  UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 200, 200) cornerRadius:65];
  CGContextRef c = UIGraphicsGetCurrentContext();
  CGContextAddPath(c, path.CGPath);
  [[UIColor redColor] set];
  CGContextStrokePath(c);
}
@end

@interface ViewController ()
@end

@implementation ViewController
- (void)viewDidLoad {
  [super viewDidLoad];
  MyView *v = [[MyView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
  [self.view addSubview:v];
}
@end
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明 在此处输入图片说明

在此处输入图片说明

drawing objective-c cgcontext ios uibezierpath

5
推荐指数
1
解决办法
610
查看次数

如何在Swift 3中使用@IBInspectable分别控制UIView的圆角?

这是我当前的代码:

override func viewDidLoad() {
    super.viewDidLoad()

    let rect = Draw(frame: CGRect(
        origin: CGPoint(x: 50, y: 50),
        size: CGSize(width: 100, height: 100)))
    self.view.addSubview(rect)
}
Run Code Online (Sandbox Code Playgroud)

uiview ios swift ibinspectable

4
推荐指数
2
解决办法
650
查看次数