我无法弄明白......我正在玩
-[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:] 因此:
bezierPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 10, 80, 80)
byRoundingCorners:(UIRectCornerBottomLeft)
cornerRadii:CGSizeMake(20, 20)];
Run Code Online (Sandbox Code Playgroud)
它按预期工作.但是,如果我用,比方说,cornerRadii:CGSizeMake(20, 5)或者替换cornerRadii:CGSizeMake(20,20)CGSizeMake(20, 40),则没有区别.
为什么是cornerRadii CGSize而不是CGFloat呢?什么是CGSize.height?
任何想法和建议将不胜感激:)

下面的简单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)

