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

 

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

时间: 2024-08-03 18:09:22

IOS项目之弹出动画终结篇的相关文章

IOS项目之弹出动画二

在IOS项目之弹出动画一中只是实现也功能,并没有体现面向对象的思想 ,今天就试着把它封装了一下,弹出视图的内容可以根据自定义,此处只是用UIDatePicker来演示 我把它传到了GitHub上   https://github.com/ywcui/YvanDatePicker.git 一.新建一个类YWDatePicker集成UIView // YvanDatePicker.h #import <UIKit/UIKit.h> typedef void (^selectDate)(NSDate

IOS项目之弹出动画一

小区宝首页导航栏左边有一个物业按钮,点击时会出现一个视图动画,之前用的是一个POP第三方,想着几个POP动画就要引用一堆的第三方有点麻烦,就试着自己写了一下,功能实现了,下一步就是优化将其封装一下.下面我用DatePicker做的主要是想着再做出点击弹出按钮在底部出现DatePicker选择器. #import "ViewController.h" #import "PageViewController.h" #import "myView.h"

如下弹出动画交果实现?求个例子

问题描述 如下弹出动画交果实现?求个例子 如图片中的效果,求一个例子!!! 解决方案 滑过显示呗!如果基础不是很好的话 ,建议先写最基础的,磨刀不误砍柴工啊 解决方案二: 如果不想亲自写可以到网上找些类似的插件,这种效果的插件有很多,好用效果又好. 解决方案三: http://www.jq22.com/jquery-info4498 参考下,类似这样.

ios-iphone中使用弹出动画

问题描述 iphone中使用弹出动画 使用了下面的代码: FirstView * fir=[[FirstView alloc]init]; [self.navigationController pushViewController:fir animated:NO]; 能否实现一个弹出动画? 谢谢 解决方案 -(void)ButtonAction:(id)sender{ [self SwipeRight:self.navigationController.view]; // <--calling

2013 向导-VS2013 新建项目不停弹出向导

问题描述 VS2013 新建项目不停弹出向导 今天打开vs2013突然发现不能新建项目了.无论是MFC还是win32,都是不停弹出向导.什么原因?该怎么解决啊?谢谢大家 解决方案 估计VS2013环境被破坏了,可以用安装包修复一下 解决方案二: 电脑最近是否安装了其他软件,比如vmvare之类的,因为此类软件会自动给VS安装一个插件.这插件有可能在每次打开的时候产生问题. 最简单的方法就是重装.别折腾了.

高仿IOS的Android弹出框_IOS

先看一下效果图,不过这是网上的图片. 效果不错,就借此拿来与大伙分享分享. github源码地址:https://github.com/saiwu-bigkoo/Android-AlertView. 1.怎么用:添加依赖. compile 'com.bigkoo:alertview:1.0.3' 2.实例demo(大家可以根据需要来选择自己需要的框框). package com.example.my.androidalertview; import android.app.Activity; i

iOS自定义提示弹出框实现类似UIAlertView的效果_php实例

首先来看看实现的效果图 下面话不多说,以下是实现的示例代码 #import <UIKit/UIKit.h> typedef void(^AlertResult)(NSInteger index); @interface XLAlertView : UIView @property (nonatomic,copy) AlertResult resultIndex; - (instancetype)initWithTitle:(NSString *)title message:(NSString

iOS自定义提示弹出框实现类似UIAlertView的效果

首先来看看实现的效果图 下面话不多说,以下是实现的示例代码 #import <UIKit/UIKit.h> typedef void(^AlertResult)(NSInteger index); @interface XLAlertView : UIView @property (nonatomic,copy) AlertResult resultIndex; - (instancetype)initWithTitle:(NSString *)title message:(NSString

一起谈.NET技术,Silverlight 游戏开发小技巧:动感弹出动画

玩Silverlight的朋友一定对自带控件ChildWindow印象深刻,Show的时候仿佛从远处弹了出来,这个效果制作起来并不复杂,下面就将介绍这个小技巧,本篇并非是一个新鲜的技巧,而是一般的故事板结合变换放缩实现. 做法也是很简单,在这里做一个抛砖引玉的小节吧:) 首先准备一个控件,这时为了更好的进行操作和控制,下面就是新建了Card控件,果断的放上了鄙人的自画像. 现在做一个放缩动画,新建一个故事板动画: 只要添加两个关键在0和0.5秒的位置即可: 下面选择开始点的关键帧位置的时间轴,将