记录一个由于代码写错导致的一个掉咋天的动画
来源:互联网 发布:淘宝不错的睡衣店知乎 编辑:程序博客网 时间:2024/06/05 18:58
// Copyright © 2017年 开太平研发1. All rights reserved.
//
#import "KtpShareAlertView.h"
#import <Masonry.h>
@interface KtpShareAlertView()<UICollectionViewDelegate,UICollectionViewDataSource>
@property ( nonatomic,strong ) UICollectionView * collectionView;
@property ( nonatomic, strong ) UIButton * cancelBtn;
@property ( nonatomic,strong ) UIView * bottomSepLine;
@property ( nonatomic, strong ) UIControl * mskView; //遮罩
@property ( nonatomic, strong ) UIView * cntView;
@property ( nonatomic, strong ) NSArray * imageList;
@property ( nonatomic, strong ) NSArray * titleList;
@end
@implementation KtpShareAlertView
+ ( void ) show {
KtpShareAlertView * shareAlertView = [[KtpShareAlertViewalloc] init];
shareAlertView.frame =CGRectMake(0,0, [UIScreenmainScreen].bounds.size.width, [UIScreenmainScreen].bounds.size.height);
[[UIApplicationsharedApplication].keyWindow addSubview:shareAlertView];
[shareAlertView showWithAnimation];
}
- ( void ) showWithAnimation {
CGAffineTransform transform =self.cntView.transform;
self.cntView.transform =CGAffineTransformScale(transform, 0,kP(120));
[UIView animateWithDuration:0.2delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.cntView.transform =CGAffineTransformScale(transform, 0,kP(-5));;
} completion:^(BOOL finished) {
[UIViewanimateWithDuration:0.2delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.cntView.transform = transform;
} completion:^(BOOL finished) {
}];
}];
}
#pragma mark
#pragma mark
#pragma mark -- button 事件响应
- ( void ) mskBtnDidClicked:(UIControl *) sender {
[selfremoveFromSuperview];
}
#pragma mark
#pragma mark
#pragma mark -- collectionView delegate,datasource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.titleList.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
KtpShareItem * item = (KtpShareItem *)[collectionViewdequeueReusableCellWithReuseIdentifier:NSStringFromClass([KtpShareItemclass]) forIndexPath:indexPath];
return item;
}
#pragma mark
#pragma mark
#pragma mark -- 生命周期
- ( instancetype ) init {
self = [superinit];
if( self ){
[selfsetBaseAttribute];
[selfsetupSubviews];
[selfsetupSubviewsLayout];
}
return self;
}
- ( void ) setBaseAttribute {
self.cntView.backgroundColor =KTPColor_White;
}
- ( void ) setupSubviews {
[selfaddSubview:self.collectionView];
[selfaddSubview:self.cancelBtn];
[selfaddSubview:self.bottomSepLine];
[selfaddSubview:self.mskView];
[selfaddSubview:self.cntView];
}
- ( void ) setupSubviewsLayout {
[self.mskViewmas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.cntViewmas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.equalTo(self);
make.height.mas_equalTo(kP(120));
}];
[self.collectionViewmas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.right.equalTo(self.collectionView);
make.height.mas_equalTo(kP(80));
}];
[self.cancelBtnmas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.collectionView.mas_bottom);
make.centerX.equalTo(self.collectionView);
}];
[self.bottomSepLinemas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.cancelBtn);
make.height.equalTo(@1);
make.top.equalTo(self.cancelBtn.mas_bottom);
}];
}
#pragma mark
#pragma mark
#pragma mark -- subviews create
- ( UICollectionView * ) collectionView {
if ( !_collectionView ) {
UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayoutalloc] init];
_collectionView = [[UICollectionViewalloc] initWithFrame:CGRectZerocollectionViewLayout:layout];
_collectionView.delegate =self;
_collectionView.dataSource =self;
[_collectionViewregisterClass:[KtpShareItemclass] forCellWithReuseIdentifier:NSStringFromClass([KtpShareItemclass])];
}
return_collectionView;
}
- ( UIButton * ) cancelBtn {
if ( !_cancelBtn ) {
_cancelBtn = [UIButtonbuttonWithType:0];
[_cancelBtnsetTitle:@"取消"forState:UIControlStateNormal];
[_cancelBtnsetTitleColor:KTPTextColor3forState:UIControlStateNormal];
_cancelBtn.titleLabel.font =KTPFont_Fit(16);
}
return_cancelBtn;
}
- ( UIControl * ) mskView {
if( !_mskView ){
_mskView = [[UIControlalloc] init];
_mskView.backgroundColor = [[UIColorblackColor] colorWithAlphaComponent:0.6];
[_mskViewaddTarget:selfaction:@selector(mskBtnDidClicked:)forControlEvents:UIControlEventTouchUpInside];
}
return_mskView;
}
- ( UIView * ) cntView {
if( !_cntView ){
_cntView = [[UIViewalloc] init];
}
return_cntView;
}
- ( UIView * ) bottomSepLine {
if( !_bottomSepLine ){
_bottomSepLine = [[UIViewalloc] init];
}
return_bottomSepLine;
}
- ( NSArray * ) titleList {
if ( !_titleList ) {
_titleList =@[@"朋友圈",@"微信好友",@"QQ好友"];
}
return_titleList;
}
- ( NSArray * ) imageList {
if ( !_imageList ) {
_imageList =@[@"fieldManagementSelect",@"fieldManagementSelect",@"fieldManagementSelect"];
}
return_imageList;
}
@end
#pragma mark
#pragma mark
#pragma mark -- KtpShareItem
@interface KtpShareItem()
@property ( nonatomic, strong ) UIImageView * iconView;
@property ( nonatomic, strong ) UILabel * titleLabel;
@end
@implementation KtpShareItem
#pragma mark
#pragma mark
#pragma mark -- setting
- ( void ) setTitle:(NSString *)title {
self.titleLabel.text = title;
}
- ( void ) setImageName:(NSString *)imageName {
self.iconView.image = [UIImageimageNamed:imageName];
}
#pragma mark
#pragma mark
#pragma mark -- 生命周期
- ( instancetype ) init {
self = [superinit];
if( self ){
[selfsetBaseAttribute];
[selfsetupSubviews];
[selfsetupSubviewsLayout];
}
return self;
}
- ( void ) setBaseAttribute {
}
- ( void ) setupSubviews {
[self.contentViewaddSubview:self.iconView];
[self.contentViewaddSubview:self.titleLabel];
}
- ( void ) setupSubviewsLayout {
[self.iconViewmas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.top.equalTo(self.contentView).offset(kP(10));
make.height.mas_equalTo(kP(30));
make.width.equalTo(self.iconView.mas_height);
}];
[self.titleLabelmas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.top.equalTo(self.iconView.mas_bottom).offset(kP(8));
}];
}
#pragma mark
#pragma mark
#pragma mark -- subviews create
- ( UIImageView * ) iconView {
if ( !_iconView ) {
_iconView = [[UIImageViewalloc] init];
}
return_iconView;
}
- ( UILabel * ) titleLabel {
if ( !_titleLabel ) {
_titleLabel = [[UILabelalloc] init];
_titleLabel.font =KTPFont_Fit(16);
_titleLabel.textColor =KTPTextColor1;
}
return_titleLabel;
}
@end
- 记录一个由于代码写错导致的一个掉咋天的动画
- 一个由于位数导致的问题
- 一个由于错误使用interval导致的错误
- 记录一个粗心所导致的bug
- 由于在写oozie hive action时候script属性指定hql脚本时多写了一个斜杠导致的一个悲剧,以及解决方案
- main方法写错导致的一个错误
- 我,一个写代码的
- 一个写代码的习惯
- 我,一个写代码的
- 我,一个写代码的
- 一个由于php代码结束符引起的技术bug
- 一个由于锁的作用域导致core dump的问题的解决
- 一个由于锁的作用域导致core dump的问题的解决
- 一个由于锁的作用域导致core dump的问题的解决
- 一个由于文件权限问题导致的SQL Server 2008 无法正常启动的问题
- 写的一个bat 循环 记录下
- 记录自己写的一个栈深搜
- 怎样判断一个查询性能低是由于缓冲池命中率导致的
- ubuntu nsq安装与配置
- Java @Override的作用
- solr集群管理
- iOS中 @try 和@catch
- SQL学习笔记[7]
- 记录一个由于代码写错导致的一个掉咋天的动画
- Bmp图片解析
- DOM级别
- 建立数据库关系图之 “ALTER TABLE 语句与 COLUMN FOREIGN KEY 约束冲突”
- jQuery的on函数的用法,如on click,on change,但是on函数
- webview图片缩放,字体大小设置,打电话
- 技术分享连载(七十二)
- asp.net MVC入门
- JZOJ 5485. 【清华集训2017模拟11.26】字符串