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(0, [UIScreen mainScreen].bounds.size.height, [UIScreen mainScreen].bounds.size.width, self.contentView.frame.size.height);
    [UIView animateWithDuration:.35 animations:^{
        self.contentView.frame = CGRectMake(0, [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:.35 animations:^{
               self.contentView.frame = CGRectMake(0, [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可以实现小区宝中的以下几个效果

 

对于这几次博客园管理员总是将我的博客移除首页,我表示遗憾。


相关文章
|
7月前
|
iOS开发
iOS 动画绘制圆形
iOS 动画绘制圆形
42 1
|
3月前
|
iOS开发
iOS App Store 上传项目报错 缺少隐私政策网址 (URL) 解决方法
iOS App Store 上传项目报错 缺少隐私政策网址 (URL) 解决方法
iOS App Store 上传项目报错 缺少隐私政策网址 (URL) 解决方法
|
9月前
|
缓存 移动开发 前端开发
iOS项目组件化历程
随着业务的发展,App中的页面,网络请求,通用弹层UI,通用TableCell数量就会剧增,需求的开发人员数量也会逐渐增多。 如果所有业务都在同一个App中,并且同时开发人数较少时,抛开代码健壮性不谈,实际的开发体验可能并没有那么糟糕,毕竟作为一个开发,什么地方用什么控件,就跟在HashMap中通过Key获取Value那么简单。 那么当业务成长到需要分化到多个App的时候,组件化的重要性开始体现了。
55 0
|
9月前
|
iOS开发 Perl
将Flutter引入到现有项目中(iOS+Flutter)
将Flutter引入到现有项目中(iOS+Flutter)
|
10月前
|
JavaScript iOS开发
iOS上架之HBuider打包简单项目及注意事项
iOS上架之HBuider打包简单项目及注意事项
|
11月前
|
开发工具 iOS开发
iOS 项目无法在模拟器运行解决办法
iOS 项目无法在模拟器运行解决办法
442 0
|
11月前
|
JavaScript iOS开发
iOS上架之hubuilder打包Vue项目
1.官网下载最新的HBuilderx。 2.准备好一个包含manifest.json的Vue项目,打开进行详细设置,设置完成后,点击保存。 3.首先去App Uploader找到开发证书(开发类型是带development的),点击证书P12下载到桌面。 4.然后根据里面的Bundle ID新建一个描述文件,把描述文件也下载到桌面。 5.菜单项点击‘发行->云打包-打原生安装包’,出现如下图所示弹框,取消广告勾选项,点击打包,把前面下载好的证书,描述文件上传到原生打包列表,提交打包,等待打包完成。(仅以iOS为例) 6.打包完成后,点击“OK”保存安装包到目标文件,发送到手机端安装即可运行。
|
存储 编解码 编译器
iOS项目Project 和 Targets配置详解
最近开始学习完整iOS项目的开发流程和思路,在实际的项目开发过程中,我们通常需要对项目代码和资料进行版本控制和管理,一般比较常用的SVN或者Github进行代码版本控制和项目管理。
689 0
|
JavaScript iOS开发
ios上架之​HBuider打包简单项目及注意事项
ios上架之​HBuider打包简单项目及注意事项
69 0
ios上架之​HBuider打包简单项目及注意事项
|
iOS开发 Perl
iOS开发 -多Target项目如何优雅的使用pods
iOS开发 -多Target项目如何优雅的使用pods
376 0