UIView的圆角矩形效果 关键是修改layer

//导入QuartzCore库

#import "QuartzCore/CALayer.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

UIView * view = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 60, 60)];

    view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"2"]];

    view.layer.cornerRadius = 6;

    view.layer.masksToBounds = YES;

    [self.view addSubview:view];

    [view release];

}


你可能感兴趣的:(UIView的圆角矩形效果 关键是修改layer)