开发者社区> 社会主义> 正文

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可以实现小区宝中的以下几个效果

 

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


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
iOS开发:下架App的步骤
首先登陆你的 iTunes Connect
189 0
2022 ios APP最新iOS开发上架测试教程
2022 ios APP最新iOS开发上架测试教程
68 0
[ios开发]-APP-上架流程
由于苹果的机制,在非越狱机器上安装必须通过官方的Appstore, 开发者开发好应用后上传Appstore,也需要通过审核等环节。 AppCan作为一个跨主流平台的一个开发平台,也对ipa包上传Appstore作了支持。 本文从三个流程来介绍如何实现AppCan在 线编译出ipa包,以及上传到苹果Appstore。
41 0
iOS开发之打包上传到App Store——(一)各种证书的理解
iOS开发之打包上传到App Store——(一)各种证书的理解
65 0
IOS APP开发:苹果app从开发到上架教程详解
IOS APP开发:苹果app从开发到上架教程详解
97 0
IOS开发:UniAPP实现BLE低功耗蓝牙开发1
1、Uni-app介绍 2、Uni-app优点 3、BLE开发流程
222 0
iOS开发 - 穿针引线之内存管理(二)
iOS开发 - 穿针引线之内存管理
45 0
+关注
社会主义
从.Net到iOS,在撸的道路上越走越远,工作之余经营着博客园http://www.cnblogs.com/5ishare,欢迎小伙伴(妹子更好)一起交流,谈谈人生理想。作为经常从网上索取免费资料的一员,要有回报回报的思想,也让更多的人少走弯路.
文章
问答
文章排行榜
最热
最新
相关电子书
更多
Facebook iOS App技术演化十年之路
立即下载
From Java_Android to Swift iOS
立即下载
深入剖析 iOS 性能优化
立即下载