Initial commit
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// DengJiView0Cell.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 17/2/28.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "DengJiView0Cell.h"
|
||||
#import "MineDengJi.h"
|
||||
@implementation DengJiView0Cell
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
|
||||
}
|
||||
|
||||
-(void)loadCellDataWith:(NSMutableArray *)dengJiArr{
|
||||
IfishUserAsset *userAsset = [dataContorl getAllIfishUserAsset];
|
||||
UIImage *levelImg =[UIImage imageNamed:@"fishrank_smallShrimp"];
|
||||
|
||||
if ([userAsset.gradeNum isKindOfClass:[NSNull class]]||!userAsset.gradeNum) {
|
||||
userAsset.gradeNum = @"1";
|
||||
}
|
||||
NSString *safeString = [NSString stringWithFormat:@"%@",userAsset.gradeNum];
|
||||
if ([safeString isEqualToString:@"1"]) {
|
||||
levelImg = [UIImage imageNamed:@"fishrank_smallShrimp"];
|
||||
}else if ([safeString isEqualToString:@"2"]){
|
||||
levelImg = [UIImage imageNamed:@"fishrank_flyFish"];
|
||||
}else if ([safeString isEqualToString:@"3"]){
|
||||
levelImg = [UIImage imageNamed:@"fishrank_crab"];
|
||||
}else if ([safeString isEqualToString:@"4"]){
|
||||
levelImg = [UIImage imageNamed:@"fishrank_yaksha"];
|
||||
}else if ([safeString isEqualToString:@"5"]){
|
||||
levelImg = [UIImage imageNamed:@"fishrank_tortoise"];
|
||||
}else if ([safeString isEqualToString:@"6"]){
|
||||
levelImg = [UIImage imageNamed:@"fishrank_dragon"];
|
||||
}else if ([safeString isEqualToString:@"7"]){
|
||||
levelImg = [UIImage imageNamed:@"fishrank_dragonking"];
|
||||
}
|
||||
|
||||
self.dengJiImg.image =levelImg;
|
||||
|
||||
if ([userAsset.gradeName isKindOfClass:[NSNull class]]||!userAsset.gradeNum) {
|
||||
userAsset.gradeName = @"小虾米";
|
||||
}
|
||||
|
||||
NSString *str =[NSString stringWithFormat:@"LV%@ %@",safeString,userAsset.gradeName];
|
||||
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:str];
|
||||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:253.0/255.0 green:145.0/255.0 blue:80.0/255.0 alpha:1] range:NSMakeRange(0,[str length])];
|
||||
[attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:15] range:NSMakeRange(0, 3)];
|
||||
[attributedString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:14] range:NSMakeRange(4,[str length]-4)];
|
||||
self.dengJIlabel.attributedText = attributedString;
|
||||
|
||||
self.startDengJi.text = [NSString stringWithFormat:@"LV%@",safeString];
|
||||
int endCode = [userAsset.gradeNum intValue];
|
||||
if ([safeString intValue]>=7) {
|
||||
self.endDengJi.text =[NSString stringWithFormat:@"满级"];
|
||||
}else{
|
||||
self.endDengJi.text =[NSString stringWithFormat:@"LV%d",endCode+1];
|
||||
}
|
||||
|
||||
int nowvalue = [userAsset.gradeValue intValue];
|
||||
self.dengJiProgress.progressColor = RGB(253, 109, 73);
|
||||
self.dengJiProgress.trackColor = RGB(227, 224, 223);
|
||||
self.dengJiProgress.pointColor = RGB(253, 109, 73);
|
||||
|
||||
|
||||
NSString * surplusStr;
|
||||
NSMutableAttributedString * surplusString;
|
||||
if ([safeString intValue]>=7) {
|
||||
surplusStr =[NSString stringWithFormat:@"已满级"];
|
||||
surplusString = [[NSMutableAttributedString alloc] initWithString:surplusStr];
|
||||
self.dengJiProgress.progress = 1.0;
|
||||
|
||||
}else{
|
||||
self.dengJiProgress.progress = [self formatDataWith:dengJiArr andLevelValue:nowvalue andlevelCode:safeString];
|
||||
int surplus = [self lastUplelvelValueWith:dengJiArr andLevelValue:nowvalue andlevelCode:safeString];
|
||||
surplusStr =[NSString stringWithFormat:@"离下一级还差%d经验值",surplus];
|
||||
surplusString = [[NSMutableAttributedString alloc] initWithString:surplusStr];
|
||||
NSString *surpNumber = [NSString stringWithFormat:@"%d",surplus];
|
||||
[surplusString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:255.0/255.0 green:193.0/255.0 blue:73.0/255.0 alpha:1] range:NSMakeRange(6,[surpNumber length])];
|
||||
}
|
||||
|
||||
self.surplusExp.attributedText =surplusString;
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(CGFloat)formatDataWith:(NSMutableArray *)arr andLevelValue:(int)levalue andlevelCode:(NSString *)leveCode
|
||||
{
|
||||
|
||||
|
||||
CGFloat percent = 0;
|
||||
|
||||
if ([arr count]!=0) {
|
||||
|
||||
for (MineDengJi *model in arr) {
|
||||
NSString *gradNum = [NSString stringWithFormat:@"%@",model.levelCode];
|
||||
if ([gradNum isEqualToString:leveCode]) {
|
||||
int total = ([model.maxValue intValue]) - ([model.minValue intValue]);
|
||||
int fenduanValue = levalue - ([model.minValue intValue]);
|
||||
NSLog(@"总分段经验值***%d",total);
|
||||
percent = (float)fenduanValue/(float)total;
|
||||
NSString *formatstr= [NSString stringWithFormat:@"%.2f",percent];
|
||||
percent = [formatstr floatValue];
|
||||
NSLog(@"percent:%f",percent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return percent;
|
||||
}
|
||||
|
||||
-(int)lastUplelvelValueWith:(NSMutableArray *)arr andLevelValue:(int)levalue andlevelCode:(NSString *)leveCode{
|
||||
|
||||
int last =0;
|
||||
if ([arr count]!=0) {
|
||||
|
||||
for (MineDengJi *model in arr) {
|
||||
NSString *gradNum = [NSString stringWithFormat:@"%@",model.levelCode];
|
||||
if ([gradNum isEqualToString:leveCode]) {
|
||||
|
||||
last = ([model.maxValue intValue]) - levalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user