• 下拉展示动画-医生工作台


    效果:
    透明色背景
    一开始白色View上的文字(箭头处)先显示出来了
     
    参考别的代码,在白色view上添加透明的背景(backView)
    必须设置clipsToBounds
    动画方法: 修改backView的高度
    如果用自动布局,效果是下面这样的,从左上角下来了

    不知道为啥是这样
    总结: 直接copy代码,仔细对比区别
    结论:大的容器view用frame, 里面的细节可以用masonory  明天问问小崔
     下面是代码:
    //
    //  HDFCheckListAlertView.h
    //  newPatient
    //
    //  Created by songximing on 16/8/11.
    //  Copyright © 2016年 haodf.com. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface HDFCheckListAlertView : UIView
    - (instancetype)initWithDoctorName:(NSString *)docName;
    @property (nonatomic, copy) HDFVoidBlock checkButtonClickBlock;
    - (void)show;
    @end
    //
    //  HDFCheckListAlertView.m
    //  newPatient
    //
    //  Created by songximing on 16/8/11.
    //  Copyright © 2016年 haodf.com. All rights reserved.
    //
    
    #import "HDFCheckListAlertView.h"
    
    @interface HDFCheckListAlertView ()
    @property (nonatomic, copy) NSString *docName; //!<医生名字
    @property (nonatomic, strong) UIView *whiteBgView; //!<背景view
    @property (nonatomic, strong) UIView *lineView;
    @property (nonatomic, strong) UIView *backView;
    @end
    
    @implementation HDFCheckListAlertView
    
    - (instancetype)initWithDoctorName:(NSString *)docName {
        if (self = [super initWithFrame:kScreenBounds]) {
            self.docName = docName;
            [self configUI];
        }
        return self;
    }
    
    - (void)configUI {
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
        
        UIView *lineView = [UIView hdf_viewWithSuperView:self constraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(200);
            make.right.mas_equalTo(-30);
            make.width.mas_equalTo(4);
            make.height.mas_equalTo(20);
        }];
        lineView.backgroundColor = kWColor;
        self.lineView = lineView;
        
        UIButton  *closeButton = [UIButton hdf_buttonWithImage:@"" superView:self constraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(lineView.mas_top);
            make.centerX.mas_equalTo(lineView);
            make.height.width.mas_equalTo(30);
        } touchup:^(UIButton *sender) {
            [self dismiss];
        }];
        closeButton.backgroundColor = [UIColor redColor];
        
        // 透明色的背景容器
        UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(20, 220, kScreenWidth - 40, 0)];
    //    UIView *backView = [UIView hdf_viewWithSuperView:self constraints:^(MASConstraintMaker *make) {
    //        make.left.mas_equalTo(20);
    //        make.top.mas_equalTo(220);
    //        make.right.mas_equalTo(-20);
    //        make.height.mas_equalTo(0);
    //    }];
        
        backView.backgroundColor = [UIColor clearColor];
        backView.clipsToBounds = YES; //!<必须写这句!!!不然没有动画效果
        [self addSubview:backView];
        self.backView = backView;
        
        // 白色的view添加到透明色背景容器上
        UIView *whiteBgView = [UIView hdf_viewWithSuperView:backView constraints:^(MASConstraintMaker *make) {
            make.left.right.top.mas_equalTo(0);
            make.height.mas_equalTo(200);
        }];
        whiteBgView.backgroundColor = kWColor;
        self.whiteBgView = whiteBgView;
    
        UILabel *titleLabel = [UILabel hdf_labelWithText:[NSString stringWithFormat:@"%@医生为您开具了检查单",self.docName] font:kFontWithSize(16) superView:whiteBgView constraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(20);
            make.centerX.mas_equalTo(0);
        }];
        
        UILabel *commentLabel = [UILabel hdf_labelWithText:@"啊哈哈哈哈哈哈(づ ̄3 ̄)づ╭❤~" font:kFontWithSize(14) superView:whiteBgView constraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(30);
            make.right.mas_equalTo(-30);
            make.top.mas_equalTo(titleLabel.mas_bottom).offset(25);
        }];
        commentLabel.numberOfLines = 0;
    
        kWeakObject(self)
        UIButton *checkButton = [UIButton hdf_buttonWithTitle:@"查看" superView:whiteBgView constraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(commentLabel.mas_bottom).offset(20);
            make.left.mas_equalTo(commentLabel);
            make.right.mas_equalTo(commentLabel);
            make.height.mas_equalTo(30);
        } touchup:^(UIButton *sender) {
            if (weakObject.checkButtonClickBlock) {
                weakObject.checkButtonClickBlock();
            }
        }];
        [checkButton setBackgroundColor:kEssentialColor];
        [checkButton setTitleColor:kWColor forState:UIControlStateNormal];
    
    }
    
    - (void)dismiss {
        [self removeFromSuperview];
    }
    
    -(void)show {
        [[UIApplication sharedApplication].keyWindow addSubview:self];
    //    self.backView.height = 0;
    //    [self.backView mas_updateConstraints:^(MASConstraintMaker *make) {
    //        make.height.mas_equalTo(200);
    //    }];
        [UIView animateWithDuration:1 animations:^{
            self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
            self.backView.height = 200;
    //        [self layoutIfNeeded];
        } completion:^(BOOL finished) {
        }];
    }
    
    @end
  • 相关阅读:
    Dump 文件生成与分析
    打造支持apk下载和html5缓存的 IIS(配合一个超简单的android APP使用)具体解释
    GridView编辑删除操作
    google域名邮箱申请 gmail域名邮箱申请(企业应用套件)指南
    nvl,空时的推断和取值
    如何将图片保存至自定义分组
    Java实现 蓝桥杯VIP 算法训练 集合运算
    Java实现 蓝桥杯VIP 算法训练 瓷砖铺放
    Java实现 蓝桥杯VIP 算法训练 瓷砖铺放
    Java实现 蓝桥杯VIP 算法训练 集合运算
  • 原文地址:https://www.cnblogs.com/tufei7/p/5816128.html
Copyright © 2020-2023  润新知