IOS设置UIView的边框为圆角

 iOS 系统自带的 View 组件都是正方形的,看起来都太生硬,有时候我需要变成圆角形式,如下图:

    具体的实现是使用QuartzCore

库,下面我具体的描述一下实现过程:

    •    首先创建一个项目,名字叫:ipad_webwiew
    •    利用Interface Builder添加一个UIWebView,然后和相应的代码相关联
    •    添加QuartzCore.framework

    代码实现:
文件
 
#import <UIKit/UIKit.h>
    
#import <QuartzCore/QuartzCore.h>
 
   
@interface ipad_webwiewViewController : UIViewController 
{
        
IBOutlet UIWebView *myWebView;
   
UIView *myView;

    
}
    
@property (nonatomic,retain) UIWebView *myWebView;
    
@end
代码实现:
    - (void)viewDidLoad 
{
       
 [super viewDidLoad];
    
    //给图层添加背景图片:
       
 //myView.layer.contents = (id)[UIImage imageNamed:@"view_BG.png"].CGImage;
        
//将图层的边框设置为圆脚

myWebView.layer.cornerRadius = 8;
 
myWebView.layer.masksToBounds = YES;
//给图层添加一个有色边框
       
 myWebView.layer.borderWidth = 5;
        
myWebView.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];
    
}

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...