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 ...
随机推荐
- MVC-controller随笔
初识MVC-controller随笔 之前用的一些其他框架,也没有系统性的学习MVC框架.最近才开始接触,给大家简单的分享一下经验. 1 MVC的核心就是Controller(控制器),它负责处 ...
- WCF快速上手(二)
服务端是CS程序,客户端(调用者)是BS程序 一.代码结构: 二.服务接口Contract和实体类Domain INoticeService: using Domain; using System; ...
- 巧用网页开发者工具F12 审查、修改元素、去除广告、屏蔽遮罩
巧用网页开发者工具F12 审查.修改元素.去除广告.屏蔽遮罩 每当打开一个网页的时候,是否为页面有很多广告而烦恼:是否为要操作页面(例如观看超清视频),请先注册登录等等事情而麻烦:是否对网页加锁的视频 ...
- C#基础笔记(第十六天)
1.进程复习//通过进程去打开应用程序 Process.Start("calc"); Process.Start("mspaint"); Process.Sta ...
- 【cocos2d-x 手游研发----博彩大转盘】
博彩大转盘,转盘抽奖的小系统,这是一个很有意思的游戏模块,游戏中增加这样一些趣味的小模块,我会附上源码: 会增进玩家的粘性,每天都想来抽两把试试手气: 我做的这个是个矩形风格的转盘,不是那种圆形的转盘 ...
- markdown字体或者图片居中
1.图片居中实例: 图片居中效果: 2.文字居中实例: 文字居中效果: 你的名字
- 【ocp-12c】最新Oracle OCP-071考试题库(40题)
40.(8-7) choose two Which two statements are true regarding views? (Choose two.) A) A simple view in ...
- 微信小程序——扫码后提示“打开失败缺少ID”
解决步骤: 进入通讯录tab->点击右上角添加朋友->搜索框输入:recover,拉到最底下选择小程序进行修复操作 参考:https://developers.weixin.qq.com/ ...
- “全栈2019”Java异常第八章:throw关键字详解
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java异 ...
- Groovy学习记录-------Groovy安装/配置
1.Groovy SDK下载 Groovy SDK官网下载地址: http://www.groovy-lang.org/download.html 每个版本有五个选项可供下载,依次为: binary ...