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

 

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

 

转载于:https://www.cnblogs.com/5ishare/p/5163893.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值