85 lines
2.7 KiB
Objective-C
85 lines
2.7 KiB
Objective-C
//
|
|
// IfishGoldAndExpTostView.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 17/3/8.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "IfishGoldAndExpTostView.h"
|
|
|
|
@implementation IfishGoldAndExpTostView
|
|
|
|
-(id)initWithFrame:(CGRect)frame{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
|
|
self.backgroundColor = [UIColor clearColor];
|
|
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)showGoldToastView:(NSString *)addValue
|
|
{//金币home_tost_gold
|
|
CGFloat W = self.frame.size.width/3;
|
|
CGFloat bakH = W*0.56;
|
|
CGFloat TopMargin = 5;
|
|
UIView *backView =[[UIView alloc] initWithFrame:CGRectMake(kScreenSize.width/2 - W/2,kScreenSize.height/2 - bakH - 20, W, bakH )];
|
|
//backView.center = self.center;
|
|
backView.backgroundColor = [UIColor blackColor];
|
|
backView.alpha = 0.8;
|
|
backView.layer.masksToBounds = YES;
|
|
backView.layer.cornerRadius = 3;
|
|
|
|
CGFloat imgH = CGRectGetHeight(backView.frame)/2-TopMargin;
|
|
|
|
UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(W/2 - imgH/2, TopMargin, imgH , imgH )];
|
|
img.image = [UIImage imageNamed:@"home_tost_gold"];
|
|
img.contentMode = UIViewContentModeScaleAspectFit;
|
|
[backView addSubview:img];
|
|
UILabel *gold = [[UILabel alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(img.frame) + 5, W, 12)];
|
|
gold.text = [NSString stringWithFormat:@"+ %@金币",addValue];
|
|
gold.textColor = RGB(252, 225, 99);
|
|
gold.textAlignment =NSTextAlignmentCenter;
|
|
[backView addSubview:gold];
|
|
|
|
[UIView animateWithDuration:1.0 delay:1.0 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
|
backView.alpha =0;
|
|
} completion:^(BOOL finished) {
|
|
[backView removeFromSuperview];
|
|
[self removeFromSuperview];
|
|
}];
|
|
|
|
|
|
[self addSubview:backView];
|
|
}
|
|
|
|
-(void)showExpTostView:(NSString *)addValue
|
|
{
|
|
|
|
CGFloat W = self.frame.size.width/3;
|
|
UIView *backView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, W, W*0.33)];
|
|
backView.center = self.center;
|
|
backView.backgroundColor = [UIColor blackColor];
|
|
backView.alpha = 0.8;
|
|
backView.layer.masksToBounds = YES;
|
|
backView.layer.cornerRadius = 3;
|
|
UILabel *exp = [[UILabel alloc] initWithFrame:CGRectMake(0,CGRectGetHeight(backView.frame)/2 - 12/2, W, 12)];
|
|
exp.text = [NSString stringWithFormat:@"+ %@点经验值",addValue];
|
|
exp.textColor = RGB(252, 225, 99);
|
|
exp.textAlignment =NSTextAlignmentCenter;
|
|
[backView addSubview:exp];
|
|
|
|
[UIView animateWithDuration:1.0 delay:2.6 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
|
backView.alpha =0;
|
|
} completion:^(BOOL finished) {
|
|
[backView removeFromSuperview];
|
|
[self removeFromSuperview];
|
|
}];
|
|
[self addSubview:backView];
|
|
|
|
}
|
|
|
|
@end
|