1.计算包裹文字cell的尺寸
-
(void)getCellWidthWithDataArray:(NSMutableArray *)dataArray{
self.widthArr = [[NSMutableArray alloc]init];
for (int i = 0; i < dataArray.count; i ++) {
NSDictionary *dataDic = self.dataArray[i];
NSString *str = dataDic[@"name"];
CGSize titleSize = [str sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]}];
CGSize size = CGSizeMake(30 + titleSize.width * baseProWidth, 15 + titleSize.height * baseProHeight);
NSNumber *number = [NSNumber numberWithFloat:size.width];[self.widthArr addObject:number];
}
}
2.从数据源中取数据,比较得到一个数组中最值,然后返回(discountArray数组有三个值,分别为最大\最小\相同):
for (int i = 0; i < weakSelf.preCardList.count; i++) {
NSNumber *rate = weakSelf.preCardList[i][@"discount_rate"];
[discountRate addObject:rate];
}
NSArray *discountArray = [discountRate sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
if ([obj1 floatValue] > [obj2 floatValue] ) {
return NSOrderedDescending;
}
if ([obj1 floatValue] < [obj2 floatValue] ) {
return NSOrderedAscending;
}
return NSOrderedSame;
}];
3.设置导航栏样式:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];