iOS基石 —— CALayer
来源:互联网 发布:playclub捏脸数据论坛 编辑:程序博客网 时间:2024/04/30 06:41
//CALayer 层(图层)//每个view(视图)都附着在一个层上 通过改变这个层 可以改变view的形状、边框、颜色等等UIView *redView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];//设置锚点 即中心点cell.layer.anchorPoint = CGPointMake(0, 0);redView.backgroundColor = [UIColor redColor];//CALayer view的属性 修改view的圆角redView.layer.cornerRadius = 20;//设置边框宽度redView.layer.borderWidth = 8.f;//设置边框颜色 颜色的CGColorredView.layer.borderColor = [UIColor greenColor].CGColor;//剪切超出的部分redView.layer.masksToBounds = YES;
//设置圆头像
UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(100, 220, 100, 100)];imageV.image = [UIImage imageNamed:@"image1"];self.view.backgroundColor = [UIColor blueColor];imageV.layer.cornerRadius = 50; imageV.layer.masksToBounds = YES;[self.view addSubview:redView];[self.view addSubview:imageV];
//动画
//CAAnimation动画类 创建按一个动画CAAnimation *anima = [CAAnimation animation];//CAAnimation 的子类 CATransitionCATransition *tans = [CATransition animation];//选择动画的类型tans.type = @"fade";//动画的方向tans.subtype = @"fromRight";//动画的时间tans.duration = 2.0;//动画的次数tans.repeatCount = 2;//在layer层上添加动画//[redView.layer addAnimation:tans forKey:@"key1"];//移除layer层的动画//[redView.layer removeAnimationForKey:@"key1"];//三维动画CABasicAnimation *baAnima = [CABasicAnimation animationWithKeyPath:@"transform"];//第一个参数:角度 x x轴 y y轴 z z轴NSValue *value = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(3.14, 2, 1, 0)];baAnima.toValue = value;baAnima.duration = 2.0;baAnima.repeatCount = 60;//在layer层上添加动画[imageV.layer addAnimation:baAnima forKey:@"key2"];
阅读全文
0 0
- iOS基石 —— CALayer
- iOS基石——UIViewController
- iOS基石——UIIage
- iOS基石——UITextField
- iOS基石——UIView
- iOS基石——NSTimer
- iOS基石—— 传值
- iOS—— CALayer 简介
- IOS开发—CALayer介绍
- iOS UI ——CALayer简介
- iOS —— CALayer 创建图层
- iOS开发UI篇—CALayer简介
- iOS开发UI篇—CALayer简介
- iOS开发UI篇—CALayer简介
- iOS开发UI篇—CALayer简介
- ios—CAlayer层的属性
- iOS开发UI篇—CALayer简介
- iOS开发UI篇—CALayer简介
- 修改Nginx web服务器默认目录
- Oracle和Mysql的分页查询语句
- 虹膜识别技术
- 数字格式化DecimalFormat
- MQTT服务器搭建--Mosquitto用户名密码配置
- iOS基石 —— CALayer
- vue初级学习-- 本地安装淘宝镜像
- Array-----74. Search a 2D Matrix(在特殊的矩阵里面快速查找)
- 如何减少APK包的大小
- maven-day01
- OSI七层模型基础知识及各层常见应用
- 安卓开发中必备的那些神器APP
- RecyclerView使用介绍
- 解决hostsplus无法安装的问题