您的位置:首页 > 其它

CALayer 圆角化、阴影、边框

2017-08-28 17:41 155 查看
//  layer层

//

//  Created by Catherine on 2017/8/28.

//  Copyright © 2017年 Catherine. All rights reserved.

//  CAlayer的属性   
圆角属性

import UIKit

class ViewController: UIViewController {

    override
func viewDidLoad() {

        super.viewDidLoad()

        // Do any additional setup after loading the view, typically from a nib.

        let imageView =
UIImageView(frame:
CGRect(x: 100, y:
100, width: 100, height:
100))

        imageView.backgroundColor =
UIColor.blue

        self.view.addSubview(imageView)

       
//设置圆角属性(会对视图进行切割)

        //imageView.layer.masksToBounds = true

        //imageView.layer.cornerRadius = 50

        //设置边框

        imageView.layer.borderWidth =
2 //两个像素的宽度

        imageView.layer.borderColor =
UIColor.magenta.cgColor

       
//设置阴影(如果视图进行了切割,那么无法显示)

        imageView.layer.shadowColor =
UIColor.purple.cgColor

        imageView.layer.shadowOffset =
CGSize(width: 10, height:
10)

        imageView.layer.shadowOpacity =
1//透明度的设置

        

    }

    override
func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: