IOS项目之弹出动画终结篇
在之前写过IOS项目之弹出动画一、IOS项目之弹出动画二、IOS项目之弹出动画三,今天来一个终极封装已经上传到Github上弹出动画总结篇UIPopoverTableView。
UIPopoverTableView也是在前面的几个基础上进行封装。如果对默认的动画效果不满意可以继承它,重写- (void)fadeIn和- (void)fadeOut方法在Github中也写了一个demo。
UIPopoverTableView本质还是一个TableView,只是在TableView的基础上增加了一些属性和方法,下面我把.H贴出来,介绍下怎么使用。
// // UIPopoverTableView.h // XQBCommunityApp // // Created by City--Online on 16/1/27. // Copyright © 2016年 CityOnline_1. All rights reserved. // #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> @class UIPopoverTableView; @protocol PopoverTableViewDelegate <NSObject> @optional //头部视图 -(UIView *)popTableHeadView:(UITableView *)tableView; //顶部试图 -(UIView *)popTableFooterView:(UITableView *)tableView; //取消 - (void)popoverTableViewCancel:(UITableView *)popTableView; @end @interface UIPopoverTableView : UITableView @property (nonatomic,strong) UIControl *overlayView; @property (nonatomic,strong) UIView *contentView; @property (nonatomic,assign) float contentViewCornerRadius; @property (nonatomic, assign) id<PopoverTableViewDelegate> popoverDelegate; //在父视图view的相对位置为Frame -(void)showInView:(UIView*)view withFrame:(CGRect)frame; //下面两个方法主要是为了子类定义弹入弹出动画 //显示的动画效果 - (void)fadeIn; //显示的动画效果 - (void)fadeOut; @end

1.PopoverTableViewDelegate协议中主要是头部、尾部和点击空白的代理方法。
2.属性
overlayView是背景层。
contentView是包括头部、尾部和中间的TableView,整个的弹出内容。
contentViewCornerRadius是设置contentView的边角。
对于有些可能要设置中间View的CornerRadius,可以设置UIPopoverTableView的CornerRadius,例如下面的效果图.

3.方法
- (void)fadeIn;- (void)fadeOut;主要是为了子类自定义contentView的弹入弹出效果。
UIPopoverTableView默认contentView的动画效果类似微信红包的效果。

如果要改变动画显示效果例如从底部弹出、或者从顶部拉出,可以继承UIPopoverTableView重现- (void)fadeIn;- (void)fadeOut;在Github中我是这样重写,主要还是对
contentView和overlayView操作。
- (void)fadeIn
{
self.contentView.frame = CGRectMake(, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width, self.contentView.frame.size.height);
[UIView animateWithDuration:. animations:^{
self.contentView.frame = CGRectMake(, [UIScreen mainScreen].bounds.size.height-self.contentView.frame.size.height, [UIScreen mainScreen].bounds.size.width, self.contentView.frame.size.height);
} completion:^(BOOL finished) {
}];
}
- (void)fadeOut{
[UIView animateWithDuration:. animations:^{
self.contentView.frame = CGRectMake(, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width, self.contentView.frame.size.height);
} completion:^(BOOL finished) {
if (finished) {
[self.overlayView removeFromSuperview];
[self.contentView removeFromSuperview];
}
}];
}
UIPopoverTableView可以实现小区宝中的以下几个效果



对于这几次博客园管理员总是将我的博客移除首页,我表示遗憾。
IOS项目之弹出动画终结篇的更多相关文章
- IOS项目之弹出动画二
在IOS项目之弹出动画一中只是实现也功能,并没有体现面向对象的思想 ,今天就试着把它封装了一下,弹出视图的内容可以根据自定义,此处只是用UIDatePicker来演示 我把它传到了GitHub上 ...
- IOS项目之弹出动画三
前面写了弹出动画两个,今天做商城时又用到了,看着这个用着蛮普遍的,所以记了下来 // // mallMoreView.h // XQB // // Created by City--Online on ...
- IOS项目之弹出动画一
小区宝首页导航栏左边有一个物业按钮,点击时会出现一个视图动画,之前用的是一个POP第三方,想着几个POP动画就要引用一堆的第三方有点麻烦,就试着自己写了一下,功能实现了,下一步就是优化将其封装一下.下 ...
- ios等待ualertview弹出动画完成后再跳转至其他页面
[self performSelector:@selector(popView:) withObject:nil afterDelay:2.0];
- 阶段一:为View设置阴影和弹出动画(天气应用)
“阶段一”是指我第一次系统地学习Android开发.这主要是对我的学习过程作个记录. 上一篇阶段一:通过网络请求,获得并解析JSON数据(天气应用)完成了应用的核心功能,接下来就要对它进行优化.今天我 ...
- mac关闭渐隐和弹出动画效果
苹果系统应用程序的窗口和对话框每次使用的时候都有华丽的特效,但是如果你感觉这种特效显得有点慢(MacGG闲的蛋疼),那该如何取消掉他呢? 方法很简单,打开"终端"(Finder-& ...
- 清除ios系统alert弹出框的域名
清除ios系统alert弹出框的域名 <script> window.alert = function(name) { var iframe = document.createElemen ...
- iOS 15 无法弹出授权弹框之解决方案---Your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 15.0
2021年9月30日下午:我正愉快的期盼着即将到来的国庆假期,时不时刷新下appstoreconnect的网址,28号就提上去的包,今天还在审核中....由于这个版本刚升级的xcode系统和新出的iO ...
- WPF制作子窗体的弹出动画效果
创建一个WPF应用程序WpfApplication1,新建个窗体DialogWin <Windowx:Class="WpfApplication1.DialogWin" xm ...
随机推荐
- ajax 与 form 提交的区别
有如下几种区别: 1. Ajax在提交.请求.接收时,都是异步进行的,网页不需要刷新:Form提交则是新建一个页面,哪怕是提交给自己本身的页面,也是需要刷新的: 2. A在提交时,是在后台新建一个请求 ...
- 【MVC】输出HTML内容,不输出HTML标签
第一种方式: @Html.Raw("内容") 第二种方式 @(new HtmlString("<h1>abcd</h1>")) 第三种方 ...
- mono+jexus 部署Asp.Net Mvc5之CompilationException2
好不容易在ubuntu上搭建了mono+jexus,欣喜若狂的部署上发布的网站,急忙打开,成功运行. 但是别高兴的太早,当我打开WebApi帮助页时出现了CompilationException. 一 ...
- .net core 2.0 mvc 初步学习
mvc_study *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !impor ...
- ceph 存储池PG查看和PG存放OSD位置
1. 查看PG (ceph-mon)[root@controller /]# ceph pg stat 512 pgs: 512 active+clean; 0 bytes data, 1936 MB ...
- java学习笔记—HTTP协议(10)
客户端浏览器和服务器Tomcat要进行基本的请求和响应的处理. 其实浏览器和服务器通信的数据的格式已经使用协议进行固定好了,只要双方发送固定格式的数据,那么就可以完成基本的通信. 如果开发者需要查看这 ...
- 初学python之路-day15
一.生成器send方法 # send的工作原理 # 1.send发送信息给当前停止的yield # 2.再去调用__next__()方法,生成器接着往下指向,返回下一个yield值并停止 # 案例: ...
- 【Oracle 12c】最新CUUG OCP-071考试题库(57题)
57.(14-17) choose two: Examine the structure of the DEPARTMENTS table You execute the following comm ...
- 【Oracle 12c】最新CUUG OCP-071考试题库(54题)
54.(12-15) choose the best answer: View the Exhibit and examine the structure of the ORDER_ITEMS and ...
- luoguP5074 Eat the Trees
https://www.luogu.org/problemnew/show/P5074 插头 $ dp $ 入门题 如果你还不会插头 $ dp $ 请右转 洛谷插头dp题解 虽然是入门题但还是逃不过分 ...