UIView上的圆angular

我很困惑我会怎么样,我已经看到约10个其他职位 ,而他们没有帮助我。 我正确地做这个?

#import "QuartzCore/QuartzCore.h" // in my ViewController.h - (void)viewDidLoad { [super viewDidLoad]; self.backgroundLayer.cornerRadius = 10.0f; } 

如果有人能帮助我,这将不胜感激。

是的,你是正确的,但设置self.backgroundLayer.layer.borderWidth ,我把下面的代码可能会对你的情况有所帮助。

为了给UIView 边界

添加#import "QuartzCore/QuartzCore.h"工作。 ( 你已经做到了

 self.backgroundLayer = [UIView alloc] initWithFrame:CGRectMake(@"As You Want")]; self.backgroundLayer.backgroundColor = [UIColor redColor]; self.backgroundLayer.layer.cornerRadius = 10.0; // set cornerRadius as you want. self.backgroundLayer.layer.borderColor = [UIColor lightGrayColor].CGColor; // set color as you want. self.backgroundLayer.layer.borderWidth = 1.0; // set borderWidth as you want. [self.view addSubView:self.backgroundLayer]; 

在你的情况下给UIView 边界

尝试开启masksToBounds 。 另外,backgroundLayer是什么?

 - (void)viewDidLoad { [super viewDidLoad]; self.view.layer.cornerRadius = 10.0f; self.view.layer.masksToBounds = YES; }