67 lines
1.9 KiB
Objective-C
67 lines
1.9 KiB
Objective-C
//
|
|
// IfishLevelUpView.m
|
|
// CollectionViewTest
|
|
//
|
|
// Created by imac on 17/3/3.
|
|
// Copyright © 2017年 xiang. All rights reserved.
|
|
//
|
|
|
|
#import "IfishLevelUpView.h"
|
|
|
|
@interface IfishLevelUpView()
|
|
@property (nonatomic,strong) UIImageView *leveUpImageView;
|
|
|
|
@end
|
|
@implementation IfishLevelUpView
|
|
|
|
-(id)initWithFrame:(CGRect)frame{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
|
|
self.backgroundColor = [UIColor clearColor];
|
|
|
|
[self creatlevelUpImg];
|
|
UIView *holdView =[[UIView alloc] initWithFrame:frame];
|
|
holdView.backgroundColor = [UIColor blackColor];
|
|
holdView.alpha = 0.6;
|
|
[self addSubview:holdView];
|
|
[self bringSubviewToFront:self.leveUpImageView];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)setImgName:(NSString *)imgName
|
|
{
|
|
self.leveUpImageView.image = [UIImage imageNamed:imgName];
|
|
}
|
|
|
|
-(void)creatlevelUpImg{
|
|
|
|
self.leveUpImageView = [[UIImageView alloc] init ];
|
|
[self addSubview:self.leveUpImageView];
|
|
|
|
[UIView animateWithDuration:0.36 delay:0 usingSpringWithDamping:25 initialSpringVelocity:20 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
|
self.leveUpImageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.width * 1.19);
|
|
} completion:^(BOOL finished){
|
|
|
|
}];
|
|
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismissSelfViewTap)];
|
|
self.leveUpImageView.userInteractionEnabled = YES;
|
|
[self.leveUpImageView addGestureRecognizer:tap];
|
|
|
|
}
|
|
|
|
-(void)dismissSelfViewTap{
|
|
|
|
__weak typeof (self)weakSelf = self;
|
|
[UIView animateWithDuration:0.36 delay:0 usingSpringWithDamping:25 initialSpringVelocity:20 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
|
weakSelf.leveUpImageView.frame = CGRectMake(0, 0, 0, 0);
|
|
} completion:^(BOOL finished) {
|
|
[weakSelf removeFromSuperview];
|
|
}];
|
|
|
|
}
|
|
|
|
@end
|