自定义一个可以动态折叠的UITAbleViewCell
看到code 4APP上有一个折叠的UITAbleViewCell,不过是swift的,所以自己尝试做一个简单的可折叠的UITAbleViewCell
主要实现一个可以折叠的UITAbleViewCell
效果图如下:
用到下面这些知识点:
1.单边圆角:
我们经常会遇到一些情况需要进行单边圆角或者边界线的设置,我简单封装了一个类别,github网址
2.锚点的更改
项目中主要围绕view上边界进行3d旋转,所以在动画之前需要进行锚点的设置。
关于锚点的详细概念,可以参考我的另一篇博客:点击这里
因为锚点改变时,frame也会变动,所以在改变锚点时需要重新设置frame。
我这里主要用下面的代码进行锚点的更改:
- (void)setAnchorPointTo:(CGPoint)point view:(UIView*)view{ /* CGRect frame = view.frame;
frame.origin.x+=(point.x - view.layer.anchorPoint.x) * view.frame.size.width;
frame.origin.y+=(point.y - view.layer.anchorPoint.y) * view.frame.size.height;
view.frame = frame;
view.layer.anchorPoint = point; */
//和上面注销掉的代码一个意思
view.frame = CGRectOffset(view.frame, (point.x - view.layer.anchorPoint.x) * view.frame.size.width, (point.y - view.layer.anchorPoint.y) * view.frame.size.height);
view.layer.anchorPoint = point;
}
3.旋转动画;
关于旋转动画,我用的是下面的方法:
[UIView animateWithDuration:0.3 animations:^{
self.ThirdView.layer.transform=CATransform3DMakeRotation(M_PI_2, , , ); }completion:^(BOOL finished) { }];
当然你也可以用这个方法:
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
[self setAnchorPointTo:CGPointMake(0.5, ) view:self.secondView];
rotationAnimation.fromValue = [NSNumber numberWithFloat: M_PI ];
rotationAnimation.toValue = [NSNumber numberWithFloat: ];
rotationAnimation.duration = ;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = ;
4.md34
利用md34属性进行类似于翻页效果的设置,关于md34属性网上有很多文章说明,这里不做详细解释。
具体代码为:
//给containView添加偏移
CATransform3D transfrom3d = CATransform3DIdentity;
transfrom3d.m34 = -0.002;
self.InnerView.layer.sublayerTransform = transfrom3d;
5.阴影:
-(void)setShadow:(UIView*)targetView{
//阴影
targetView.layer.shadowOpacity = 1.0;// 阴影透明度
targetView.layer.shadowColor = [UIColor grayColor].CGColor;// 阴影的颜色
targetView.layer.shadowRadius = ;// 阴影扩散的范围控制
targetView.layer.shadowOffset = CGSizeMake(, );// 阴影的范围
}
Demo地址:点击这里
有什么bug,还请告知。
自定义一个可以动态折叠的UITAbleViewCell的更多相关文章
- JSTL,自定义一个标签的功能案例
1.自定义一个带有两个属性的标签<max>,用于计算并输出两个数的最大值: 2.自定义一个带有一个属性的标签<lxn:readFile src=“”>,用于输出指定文件的内容 ...
- springboot+zuul(一)------实现自定义过滤器、动态路由、动态负载。
参考:https://blog.csdn.net/u014091123/article/details/75433656 https://blog.csdn.net/u013815546/articl ...
- 在Dynamics CRM中自定义一个通用的查看编辑注释页面
关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复162或者20151016可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me! 注释在CRM中的显示是比较特别, ...
- SpringMVC 自定义一个拦截器
自定义一个拦截器方法,实现HandlerInterceptor方法 public class FirstInterceptor implements HandlerInterceptor{ /** * ...
- jQuery Validate 表单验证插件----自定义一个验证方法
一.下载依赖包 网盘下载:https://yunpan.cn/cryvgGGAQ3DSW 访问密码 f224 二.引入依赖包 <script src="../../scripts/j ...
- Spring自定义一个拦截器类SomeInterceptor,实现HandlerInterceptor接口及其方法的实例
利用Spring的拦截器可以在处理器Controller方法执行前和后增加逻辑代码,了解拦截器中preHandle.postHandle和afterCompletion方法执行时机. 自定义一个拦截器 ...
- 自定义View(7)官方教程:自定义View(含onMeasure),自定义一个Layout(混合组件),重写一个现有组件
Custom Components In this document The Basic Approach Fully Customized Components Compound Controls ...
- Volley HTTP库系列教程(5)自定义一个Volley请求
Implementing a Custom Request Previous Next This lesson teaches you to Write a Custom Request parse ...
- 在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性:
在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性: var s = new MyString("hello"); s ...
随机推荐
- jar包获取资源文件
背景 写的一个spring boot项目打成jar包部署运行下,打成jar包,提示找不到资源文件,如下图: 直接通过idea是可以运行的,但打成jar包后提示找不到资源文件,简单查阅后了解到是因为ja ...
- 通过EntityFramework操作sqlite(DbFirst)
记录一下通过 EntityFramework6 来操作sqlite过程 环境: visual studio 2017 .net 4.5 Console Application(项目类型) sqlite ...
- 5. ASP.NET MVC 中的Areas【区域】是什么
[PS返回上一篇:-->4.ASP.NET MVC 5.0 视图之模型绑定] 从ASP.NET MVC 2.0开始,微软就提供了一个新特性:Areas[区域].Areas仅仅是用来将大型程序拆分 ...
- CODE FIRST之空数据模型
1.首先添加空Code Firtst模型 2.新建两个实体类,关系一对多 public class UserInfo { public UserInfo() { OrderInfo = new Has ...
- 【转】PowerDesigner删除外键关系,而不删除外键列
原文:https://blog.csdn.net/tomsyc/article/details/6075530 PowerDesigner中配置外键关系时,如果要删除配置的外键关系,默认设置会一同删除 ...
- python--Websocket实现, 加密 sha1,base64
需要用到gevent-websocket包,这里我们用下图这个 一.websocket简单实现 ep1.py from geventwebsocket.handler import WebSocket ...
- pyqt5 Button.click 报错:argument 1 has unexpected type 'NoneType'
如上所示,在括号中,添加‘lambda:’,就可以成功运行,不知道为啥. 参考:https://blog.csdn.net/flhsxyz/article/details/79220936?utm_s ...
- jQuery基础(3)- ajax
一.jQuery的ajax 1.什么是ajax AJAX = 异步的javascript和XML(Asynchronous Javascript and XML). 简言之,在不重载整个网页的情况下, ...
- IOS渗透测试第一步-基础知识统一放送
原文: http://www.websecgeeks.com/2017/04/ios-application-pentesting-part-3.html http://www.websecgeeks ...
- Android自定义组合控件详细示例 (附完整源码)
在我们平时的Android开发中,有时候原生的控件无法满足我们的需求,或者经常用到几个控件组合在一起来使用.这个时候,我们就可以根据自己的需求创建自定义的控件了,一般通过继承View或其子类来实现. ...