人在身處逆境時(shí)苛茂,適應(yīng)環(huán)境的能力實(shí)在驚人。人可以忍受不幸鸠窗,也可以戰(zhàn)勝不幸妓羊,因?yàn)槿擞兄@人的潛力,只要立志發(fā)揮它稍计,就一定能渡過難關(guān)躁绸。——卡耐基
string的category:
/** 獲取指定的制定文字
@param str 文字
@param textColor 文字顏色
@param heigt_lineSpacing 文字間行高
@param font_one 文字字號
@return 輸出文字 */
+ (NSAttributedString *) attributedBaseTextWithStr:(NSString *) str withColor:(UIColor *) textColor withLine:(CGFloat)heigt_lineSpacing withFont:(CGFloat)font_one {
NSMutableParagraphStyle *paraStyle01 = [[NSMutableParagraphStyle alloc] init];
paraStyle01.lineSpacing = heigt_lineSpacing;
NSDictionary *attrDict01 = @{NSParagraphStyleAttributeName: paraStyle01, NSFontAttributeName: [UIFont systemFontOfSize: font_one] , NSForegroundColorAttributeName: textColor}; NSAttributedString * attriBuStr = [[NSAttributedString alloc] initWithString:str attributes:attrDict01];
return attriBuStr;
}
/** 字符串轉(zhuǎn)時(shí)間 yyyy-MM-dd */
+ (NSDate *) dateWithString:(NSString *) str {
NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];//實(shí)例化一個(gè)NSDateFormatter對象
[dateFormat setDateFormat:@"yyyy-MM-dd"];//設(shè)定時(shí)間格式,這里可以設(shè)置成自己需要的格式
NSDate *date =[dateFormat dateFromString:str];
return date;
}
/** 字符串轉(zhuǎn)時(shí)間 yyyy-MM */
+ (NSDate *) dateMonthWithString:(NSString *) str {
NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init];//實(shí)例化一個(gè)NSDateFormatter對象
[dateFormat setDateFormat:@"yyyy-MM"];//設(shè)定時(shí)間格式,這里可以設(shè)置成自己需要的格式
NSDate *date =[dateFormat dateFromString:str];
return date;
}
/** 時(shí)間轉(zhuǎn)字符串 */
+ (NSString * ) strWithDate:(NSDate *) date {
NSDateFormatter * dateFormat = [[NSDateFormatter alloc] init];//實(shí)例化一個(gè)NSDateFormatter對象
[dateFormat setDateFormat:@"yyyy-MM"];//設(shè)定時(shí)間格式,這里可以設(shè)置成自己需要的格式 //
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *currentDateStr = [dateFormat stringFromDate:date];
return currentDateStr;
}
+ (NSString * ) strWithdayDate:(NSDate *) date {
NSDateFormatter * dateFormat = [[NSDateFormatter alloc] init];//實(shí)例化一個(gè)NSDateFormatter對象
[dateFormat setDateFormat:@"yyyy-MM-dd"];//設(shè)定時(shí)間格式,這里可以設(shè)置成自己需要的格式 // [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];/
NSString *currentDateStr = [dateFormat stringFromDate:date];
return currentDateStr;
}
/** 時(shí)間轉(zhuǎn)換成字符串 yyyy-MM-dd HH:mm:ss */
+ (NSString * ) strWithhouryDate:(NSDate *) date {
NSDateFormatter * dateFormat = [[NSDateFormatter alloc] init];//實(shí)例化一個(gè)NSDateFormatter對象
[dateFormat setDateFormat:@"yyyy-MM-dd HH:mm"];//設(shè)定時(shí)間格式,這里可以設(shè)置成自己需要的格式 // [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];/
NSString *currentDateStr = [dateFormat stringFromDate:date];
return currentDateStr; }
/** 時(shí)間轉(zhuǎn)換成字符串 yyyy-MM-dd HH:mm */
+ (NSString * ) strWithsecondDate:(NSDate *) date {
NSDateFormatter * dateFormat = [[NSDateFormatter alloc] init];//實(shí)例化一個(gè)
NSDateFormatter對象 [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];//設(shè)定時(shí)間格式,這里可以設(shè)置成自己需要的格式 // [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];/
NSString *currentDateStr = [dateFormat stringFromDate:date];
return currentDateStr;
}
溫故而知新!