相关疑难解决方法(0)

为什么CGSize的cornerRadii参数键入 - [UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:]?

我无法弄明白......我正在玩

-[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

任何想法和建议将不胜感激:)

在此输入图像描述 在此输入图像描述

uikit ios uibezierpath

19
推荐指数
2
解决办法
5598
查看次数

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
查看次数

标签 统计

ios ×2

uibezierpath ×2

cgcontext ×1

drawing ×1

objective-c ×1

uikit ×1