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.
}
}
//
// 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.
}
}
相关文章推荐
- 如何消除自定义AlertDialog圆角化的阴影或者黑色边框
- CALayer的使用(圆形头像 锚点 边框 阴影 形变 隐式动画 )
- iOS效果 :(1) CALayer 图层阴影,边框,圆角,圆型图片的阴影
- CALayer控件(通过操作这个CALayer对象,可以很方便地调整UIView的一些界面属性,比如:阴影、圆角大小、边框宽度和颜色等)
- (一一九)通过CALayer实现阴影、圆角、边框和3D变换
- (一一九)通过CALayer实现阴影、圆角、边框和3D变换
- 1.给图像添加阴影、边框和圆角 2。CALayer的隐式动画
- 纯css实现边框阴影
- 图片立体边框效果,图片阴影效果
- 动画—CALayer的初步学习三:CALayer绘图—通过代理方法绘图扩展1.2(带阴影效果的绘图和图层的形变)(学会从博客上自学)
- 设置UIView阴影shadow 边框 边框颜色
- Swift-UIStoryboard & Xib 实时设置控件圆角、边框、阴影
- html边框阴影效果的实现
- android shape的使用详解以及常用效果(渐变色、分割线、边框、半透明阴影效果等)
- 边框为阴影效果
- iphone ios uiview uilabel 边框,圆角,阴影实现
- android ImageView 加边框, 加阴影,shadow
- Qt之阴影边框
- IOS UIView圆角,阴影,边框,渐增光泽
- css3 边框阴影效果