UIView上的圆角 [英] Rounded corners on UIView
本文介绍了UIView上的圆角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对如何绕过角落感到困惑,我已经看到其他10个帖子,而且他们没有帮助过我。我这样做是否正确?
I am confused on how I would round corners, I've seen about 10 other posts and non of them have helped me. Am I doing this correctly?
#import "QuartzCore/QuartzCore.h" // in my ViewController.h
- (void)viewDidLoad
{
[super viewDidLoad];
self.backgroundLayer.cornerRadius = 10.0f;
}
如果有人可以帮我解决这个问题,我将不胜感激。
If somebody could help me out on this it'd be greatly appreciated.
推荐答案
是的,你是对的,但设置 self.backgroundLayer.layer.borderWidth
,我把下面的代码对你的情况有帮助。
Yes, You are correct but set self.backgroundLayer.layer.borderWidth
, I put following code might be helpful in your case.
给圆边框 UIView
。
添加 #importQuartzCore / QuartzCore.h
fram work。 (你已经完成了)
Add #import "QuartzCore/QuartzCore.h"
fram work. (you've already done it)
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
。
这篇关于UIView上的圆角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文