ios弹出式效果

文章实现iOS弹出式效果,有阴影有透明度。

方法一:

项目中引入YZSheetView.h,YZSheetView具体实现如下。

YZSheetView.h

#import <UIKit/UIKit.h>


@interface YZSheetView : UIActionSheet


@property (retain,nonatomic)UIView *contentView;

- (void)disMissView;

@end

YZSheetView.m

#import "YZSheetView.h"


@implementation YZSheetView


/*

// Only override drawRect: if you perform custom drawing.

// An empty implementation adversely affects performance during animation.

- (void)drawRect:(CGRect)rect {

    // Drawing code

}

*/

- (id)initWithFrame:(CGRect)frame

{

    if (self == [superinitWithFrame:frame])

    {

        [selfinitContent];

    }

    

    returnself;

}


- (void)initContent

{

    self.frame =CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);

    

    //alpha 0.0  白色   alpha 1:黑色   alpha 01:遮罩颜色,逐渐

    self.backgroundColor = [UIColorcolorWithRed:0green:0blue:0alpha:0.4];

    self.userInteractionEnabled =YES;

    [selfaddGestureRecognizer:[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(disMissView)]];

    

    if (_contentView ==nil)

    {

        _contentView = [[UIViewalloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT - 384-69,SCREEN_WIDTH,384)];

        _contentView.backgroundColor = [UIColorredColor];

        [selfaddSubview:_contentView];

    }

}


- (void)loadMaskView

{

}


//展示从底部向上弹出的UIView(包含遮罩)

- (void)showInView:(UIView *)view

{

    if (!view)

    {

        return;

    }

    

    [view addSubview:self];

    [view addSubview:_contentView];

    

    [_contentViewsetFrame:CGRectMake(0,SCREEN_HEIGHT,SCREEN_WIDTH,384)];

    

    [UIViewanimateWithDuration:0.3animations:^{

        

        self.alpha =1.0;

        

        [_contentViewsetFrame:CGRectMake(0,SCREEN_HEIGHT - 384-69,SCREEN_WIDTH,384)];

        

    } completion:nil];

}


//移除从上向底部弹下去的UIView(包含遮罩)

- (void)disMissView

{

    [_contentViewsetFrame:CGRectMake(0,SCREEN_HEIGHT - 384-69,SCREEN_WIDTH,384)];

    [UIViewanimateWithDuration:0.3f

                     animations:^{

                         

                         self.alpha =0.0;

                         

                         [_contentViewsetFrame:CGRectMake(0,SCREEN_HEIGHT,SCREEN_WIDTH,384)];

                     }

                     completion:^(BOOL finished){

                         

                         [selfremoveFromSuperview];

                         [_contentViewremoveFromSuperview];

                         

                     }];

    

}


@end

YZSheetView的引用:

    _tfSheetView = [[YZSheetViewalloc]init];

    [_tfSheetView.contentViewaddSubview:orderDetView];

    priceLabel.text = [NSStringstringWithFormat:@"%@",self.totalprice];

显示:

    [_tfSheetViewshowInView:self.view];

隐藏:

    [_tfSheetViewdisMissView];



方法二:

pod 'SnailPopupController','~> 2.0.5'


- (IBAction)filtAction:(id)sender {

    filtView.frame =CGRectMake(70,0, SCREEN_WIDTH-70,SCREEN_HEIGHT); 

    self.sl_popupController = [SnailPopupControllernew];

    self.sl_popupController.layoutType =PopupLayoutTypeRight;

    self.sl_popupController.allowPan =YES;

    [self.sl_popupControllerpresentContentView:filtView];

    

}

- (IBAction)cancelFlitAction:(id)sender {

    [self.sl_popupControllerdismiss];


}



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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值