前面写了弹出动画两个,今天做商城时又用到了,看着这个用着蛮普遍的,所以记了下来

//
//  mallMoreView.h
//  XQB
//
//  Created by City--Online on 15/7/6.
//
//

#import <UIKit/UIKit.h>

typedef  void (^SelectMallMoreMenu)(NSInteger index);
@interface mallMoreView : UIView

//单例
+ (mallMoreView *)sharedManager;

//block传值
@property(nonatomic,strong) SelectMallMoreMenu selectMallMoreMenu;

@property(nonatomic,strong) NSArray *titles;
@property(nonatomic,strong) UITableView *tableView;

//window全屏显示
-(void)showInWindow;

// View中显示
-(void)showInView:(UIView*)view;

//在父视图view的相对位置为Frame
-(void)showInView:(UIView*)view withFrame:(CGRect)frame;

//消失视图
-(void)dismissView;
@end
//
//  mallMoreView.m
//  XQB
//
//  Created by City--Online on 15/7/6.
//
//

#import "mallMoreView.h"
#import "Global.h"
@interface mallMoreView ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,assign) BOOL open;
@end

@implementation mallMoreView

+ (mallMoreView *)sharedManager
{
    static mallMoreView *managerInstance = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        managerInstance = [[self alloc] init];
        managerInstance.backgroundColor=[UIColor colorWithWhite:0.1 alpha:0.1];

    });
    return managerInstance;
}
-(void)showInWindow
{

    [self showInView:[UIApplication sharedApplication].keyWindow];
}
-(void)showInView:(UIView*)view
{
    [self showInView:view withFrame:CGRectMake(, , view.frame.size.width, view.frame.size.height)];

}
-(void)showInView:(UIView*)view withFrame:(CGRect)frame
{
    if (_open) {
        [self dismissView];
        return;
    }
    _open=true;

    UITapGestureRecognizer *tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismissView)];
    [self addGestureRecognizer:tapGesture];
    self.frame=CGRectMake(, , frame.size.width, frame.size.height);

    self.alpha=0.0;

    if (_tableView==nil) {
        _tableView=[[UITableView alloc]init];
    }
    _tableView.delegate=self;
    _tableView.dataSource=self;
    _tableView.backgroundColor=[UIColor colorWithWhite:0.2 alpha:0.5];
    _tableView.tableHeaderView=[[UIView alloc]initWithFrame:CGRectZero];
    _tableView.tableFooterView=[[UIView alloc]initWithFrame:CGRectZero];
    [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];

    //动画效果
    [UIView animateWithDuration: options:UIViewAnimationOptionCurveEaseOut animations:^{
        self.alpha=1.0;
        _tableView.hidden=NO;
      } completion:nil
    ];
    [view addSubview:self];

    //要将TableView添加到view而不是self,否则不能选中TableView
    [view addSubview:_tableView];

}
-(void)dismissView
{
    _open=false;
    [UIView animateWithDuration: options:UIViewAnimationOptionCurveEaseOut animations:^{
        self.alpha=0.0;
        _tableView.hidden=YES;
    } completion:^(BOOL finished) {

        [self removeFromSuperview];
        [_tableView removeFromSuperview];
    }];

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _titles.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    cell.backgroundColor=[UIColor clearColor];
    cell.textLabel.text=[_titles objectAtIndex:indexPath.row];
    cell.textLabel.textColor=[UIColor whiteColor];
    cell.textLabel.font=[UIFont systemFontOfSize:];
    cell.textLabel.textAlignment=NSTextAlignmentCenter;
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ) {
        ;
    }
    return tableView.frame.size.height/_titles.count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    _selectMallMoreMenu(indexPath.row);
    [self dismissView];
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }

#ifdef __IPHONE_8_0
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }

    if([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]){
        [cell setPreservesSuperviewLayoutMargins:NO];
    }
#endif
}

@end
-(void)popMallMoreView:(id)sender
{
    mallMoreView *moreView=[mallMoreView sharedManager];
    moreView.tableView=[[UITableView alloc]init];
    moreView.tableView.frame=CGRectMake(MAINWIDTH-, , , );
    moreView.titles=@[@"回到首页",@"闪购订单",@"收货地址"];
    moreView.selectMallMoreMenu=^(NSInteger index)
    {
        NSLog(@"%ld",index);
    };
    [moreView showInView:self.view];

}

IOS项目之弹出动画三的更多相关文章

  1. IOS项目之弹出动画终结篇

    在之前写过IOS项目之弹出动画一.IOS项目之弹出动画二.IOS项目之弹出动画三,今天来一个终极封装已经上传到Github上弹出动画总结篇UIPopoverTableView. UIPopoverTa ...

  2. IOS项目之弹出动画二

    在IOS项目之弹出动画一中只是实现也功能,并没有体现面向对象的思想 ,今天就试着把它封装了一下,弹出视图的内容可以根据自定义,此处只是用UIDatePicker来演示 我把它传到了GitHub上    ...

  3. IOS项目之弹出动画一

    小区宝首页导航栏左边有一个物业按钮,点击时会出现一个视图动画,之前用的是一个POP第三方,想着几个POP动画就要引用一堆的第三方有点麻烦,就试着自己写了一下,功能实现了,下一步就是优化将其封装一下.下 ...

  4. ios等待ualertview弹出动画完成后再跳转至其他页面

    [self performSelector:@selector(popView:) withObject:nil afterDelay:2.0];

  5. 阶段一:为View设置阴影和弹出动画(天气应用)

    “阶段一”是指我第一次系统地学习Android开发.这主要是对我的学习过程作个记录. 上一篇阶段一:通过网络请求,获得并解析JSON数据(天气应用)完成了应用的核心功能,接下来就要对它进行优化.今天我 ...

  6. mac关闭渐隐和弹出动画效果

    苹果系统应用程序的窗口和对话框每次使用的时候都有华丽的特效,但是如果你感觉这种特效显得有点慢(MacGG闲的蛋疼),那该如何取消掉他呢? 方法很简单,打开"终端"(Finder-& ...

  7. 清除ios系统alert弹出框的域名

    清除ios系统alert弹出框的域名 <script> window.alert = function(name) { var iframe = document.createElemen ...

  8. iOS学习——键盘弹出遮挡输入框问题解决方案

    在iOS或Android等移动端开发过程中,经常遇到很多需要我们输入信息的情况,例如登录时要输入账号密码.查询时要输入查询信息.注册或申请时需要填写一些信息等都是通过我们键盘来进行输入的,在iOS开发 ...

  9. 原生Js_实现简单的下拉折叠菜单(添加弹出动画效果)

    用javascript实现简单的下拉折叠菜单效果 实现步骤 (a)获得各操作的dom对象: (b)在所有菜单按钮对象上添加单击事件: (c)设置所有菜单按钮样式为空,并将当前按钮的样式设置为“acti ...

随机推荐

  1. unity 分数的显示

    通常 在完成 条件之后再增加分数 所以 一开始先增加 public int 得到分数; public Text 分数ui; 在完成条件后增加 得到分数++; 分数ui.text = 得到分数.ToSt ...

  2. Caffe任务池GPU模型图像识别

    一开始我在网上找demo没有找到,在群里寻求帮助也没有得到结果,索性将网上的易语言模块反编译之后,提取出对应的dll以及代码,然后对照官方的c++代码,写出了下面的c#版本 /*** * @pName ...

  3. iOS 安装包瘦身 (上篇)

    本文来自网易云社区 作者:饶梦云 1. 安装包组成 谈到 App 瘦身,最直接的想法莫过于分析一个安装包内部结构,了解其每一部分的来源.解压一个 ipa 包,拿到其 payload 中 app 文件的 ...

  4. python 杂谈

    python 当前文件导入自定义模块的时候,会默认执行一遍 python使用的变量必须是已经定义或者声明过的.

  5. Remoteland HDU - 4196

    题意: 给出一个n,在[1, n] 中挑选几个不同的数相乘,求能的到的最大完全平方数 解析: 最大的肯定是n!, 然后n!不一定是完全平方数 (我们知道一个完全平方数,质因子分解后,所有质因子的质数均 ...

  6. objectARX创建 PaletteSet 停靠面板示例

    objectARX创建 PaletteSet 停靠面板示例 图文By edata ,转载注明出处 http://www.cnblogs.com/edata 部分代码参考张帆<AutoCAD Ob ...

  7. iOS 计算文字宽度的一个细节

    设计师给到的图,经常是 "按钮的左边距离文字右边5px" 这样子的标注.于是我们需要计算文字的宽度. 有两种方法: 用 label 或 button 的 sizetofit 方法 ...

  8. leetcode-896-单调数列

    题目描述: 如果数组是单调递增或单调递减的,那么它是单调的. 如果对于所有 i <= j,A[i] <= A[j],那么数组 A 是单调递增的. 如果对于所有 i <= j,A[i] ...

  9. L02-RHEL6.5环境中安装JDK1.8

    注: 1.本文安装的是jdk1.8,采用rpm包的方式安装. 2.rpm安装方式默认会把jdk安装到/usr/java/jdk1.8xxx 路径上,若想将JDK安装到特定路径,需以源码方式安装,可参考 ...

  10. shell-012:批量创建用户

    # #!/bin/bash # 批量创建用户 # 分析:用命令给用户创建密码的方法有两种 # . 可以直接用echo的方法 # echo "abc-123" |passwd roo ...