iOS常用技术-图片圆角

 1 //
 2 //  ViewController.m
 3 //  图片圆角
 4 //
 5 //  Created by 大欢 on 16/1/20.
 6 //  Copyright © 2016年 bjsxt. All rights reserved.
 7 //
 8 
 9 #import "ViewController.h"
10 
11 @interface ViewController ()
12 
13 @end
14 
15 @implementation ViewController
16 
17 - (void)viewDidLoad {
18     [super viewDidLoad];
19     
20     //CALayer:决定UIView样式的类
21     
22     UIImage * image = [UIImage imageNamed:@"touxiang.jpg"];
23     UIImageView * imageView = [[UIImageView alloc] initWithImage:image];
24     imageView.frame = CGRectMake(100, 100, 100, 100);
25     
26     //给图片加圆角
27 //    imageView.layer.cornerRadius = 50;
28 //    imageView.layer.masksToBounds = YES;
29 //    imageView.clipsToBounds = YES;
30 //    设置边线宽度
31     imageView.layer.borderWidth = 2;
32 //    设置边线颜色
33     imageView.layer.borderColor = [UIColor blackColor].CGColor;
34     //阴影颜色
35     imageView.layer.shadowColor = [UIColor redColor].CGColor;
36     //阴影大小
37     imageView.layer.shadowOffset = CGSizeMake(10,10);
38     //不透明度
39     imageView.layer.shadowOpacity = 0.3;
40     [self.view addSubview:imageView];
41 }
42 
43 - (void)didReceiveMemoryWarning {
44     [super didReceiveMemoryWarning];
45     // Dispose of any resources that can be recreated.
46 }
47 
48 @end


/********************************************************/

原文地址:https://www.cnblogs.com/MrWuYindi/p/5146667.html