看到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的更多相关文章

  1. JSTL,自定义一个标签的功能案例

    1.自定义一个带有两个属性的标签<max>,用于计算并输出两个数的最大值: 2.自定义一个带有一个属性的标签<lxn:readFile  src=“”>,用于输出指定文件的内容 ...

  2. springboot+zuul(一)------实现自定义过滤器、动态路由、动态负载。

    参考:https://blog.csdn.net/u014091123/article/details/75433656 https://blog.csdn.net/u013815546/articl ...

  3. 在Dynamics CRM中自定义一个通用的查看编辑注释页面

    关注本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复162或者20151016可方便获取本文,同时可以在第一时间得到我发布的最新的博文信息,follow me! 注释在CRM中的显示是比较特别, ...

  4. SpringMVC 自定义一个拦截器

    自定义一个拦截器方法,实现HandlerInterceptor方法 public class FirstInterceptor implements HandlerInterceptor{ /** * ...

  5. jQuery Validate 表单验证插件----自定义一个验证方法

    一.下载依赖包 网盘下载:https://yunpan.cn/cryvgGGAQ3DSW  访问密码 f224 二.引入依赖包 <script src="../../scripts/j ...

  6. Spring自定义一个拦截器类SomeInterceptor,实现HandlerInterceptor接口及其方法的实例

    利用Spring的拦截器可以在处理器Controller方法执行前和后增加逻辑代码,了解拦截器中preHandle.postHandle和afterCompletion方法执行时机. 自定义一个拦截器 ...

  7. 自定义View(7)官方教程:自定义View(含onMeasure),自定义一个Layout(混合组件),重写一个现有组件

    Custom Components In this document The Basic Approach Fully Customized Components Compound Controls ...

  8. Volley HTTP库系列教程(5)自定义一个Volley请求

    Implementing a Custom Request Previous  Next This lesson teaches you to Write a Custom Request parse ...

  9. 在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性:

    在String()构造器不存在的情况下自定义一个MyString()函数,实现如下内建String()方法和属性: var s = new MyString("hello"); s ...

随机推荐

  1. ModelValidator基于元数据的验证

    ModelValidator主要是应用在ModelMetadata元数据的类型上或类型属性上.它是验证的基础类型,所有的ModelValidatorProviders.DataAnnotationVa ...

  2. Android开发教程 - 使用Data Binding(四)在Fragment中的使用

    本系列目录 使用Data Binding(一)介绍 使用Data Binding(二)集成与配置 使用Data Binding(三)在Activity中的使用 使用Data Binding(四)在Fr ...

  3. 自用 docker-compose

    version: '3.1' services: mysql: image: mysql: command: --default-authentication-plugin=mysql_native_ ...

  4. Spring Boot中使用@Scheduled创建定时任务

    我们在编写Spring Boot应用中经常会遇到这样的场景,比如:我需要定时地发送一些短信.邮件之类的操作,也可能会定时地检查和监控一些标志.参数等. 创建定时任务 在Spring Boot中编写定时 ...

  5. spring mvc 使用kaptcha配置生成验证码实例

    SpringMVC整合kaptcha(验证码功能) 一.依赖 <dependency> <groupId>com.github.penggle</groupId> ...

  6. 【转】如何用css限制文字长度,使溢出的内容用省略号…显示

    文章转自这里(现在貌似被黑了,建议不要点击了) ps:因在该地方没看到转载按钮,复制下存到这里以待自己方便,别人能看到帮助一下更是乐意之至,效果亲测可以实现,兼容IE.谷歌.火狐 由于文字内容长度的不 ...

  7. 常用处理数据用法es6 语法糖总结

    一 循环(数组 ,集合)   1 forEach-----------可以遍历得到vaue和index   const arr = ['red', 'green', 'blue'];arr.forEa ...

  8. (转)Linux top命令的用法详细详解

    原文:https://yq.aliyun.com/articles/399004?spm=a2c4e.11153940.blogcont399002.9.3a19f00aHOA3SH# 摘要: 首先介 ...

  9. ubuntu安装ruby的几种方法总结

    1.apt-get安装 可以使用apt-cache查询功能,找到对应的可用的ruby版本. $ sudo apt-cache search ruby #这个结果很长,我只截取最后与ruby有关的部分 ...

  10. 二、LINQ之查询表达式基础

    1.查询是什么? 查询是一组指令,描述要从给定数据源(或源)检索的数据以及返回的数据应具有的形状和组织.查询表达式和它所产生的结果不同.