码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-08-28 22:33:48      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:

效果:
技术分享

 

透明色背景
一开始白色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

 

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

标签:

原文地址:http://www.cnblogs.com/tufei7/p/5816128.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!