[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString”];
<span style="font-family: HannotateSC-W5;">获得build号</span>
[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
//比较两个日期的大小,只比较到具体的某一天
-(NSComparisonResult)compareDay:(NSDate *)oneDay anotherDay:(NSDate *)anotherDay{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSString *oneDayStr = [dateFormatter stringFromDate:oneDay];
NSString *anotherDayStr = [dateFormatter stringFromDate:anotherDay];
NSDate *dateA = [dateFormatter dateFromString:oneDayStr];
NSDate *dateB = [dateFormatter dateFromString:anotherDayStr];
NSComparisonResult result = [dateA compare:dateB];
return result;
}
使用时[selfcompareDay:dateanotherDay:currentDay]==NSOrderedAscending 表示curentDay大于date
/*根据字符串的格式计算uilabel的宽高
*str —— 要计算size的字符串
*space —— 行间距
*strFont —— 字体
*maxSize —— 字符串允许的最大的宽高size
*/
-(CGSize)countStrSize:(NSString *)str lineSpace:(float)space font:(UIFont *)strFont maxSize:(CGSize)maxSize{
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]init];
if (str) {
attributedString = [[NSMutableAttributedString alloc] initWithString:str];
}
//maxSize 如CGSizeMake(320 - xybImgLeftMargin*3-imgViewWidth, MAXFLOAT)
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:space];//调整行间距
NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:15],NSParagraphStyleAttributeName:paragraphStyle};
[attributedString addAttributes:attributes range:NSMakeRange(0, [str length])];
CGRect detailFrame =[attributedString boundingRectWithSize:maxSize
options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading context:nil];
CGSize detailSize = detailFrame.size;
//textLabel.attributedText = attributedString;
return detailSize;
}