1. 判斷一個(gè)時(shí)間是否在另外一段時(shí)間內(nèi)
- (BOOL)date:(NSDate*)date isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate {
if ([date compare:beginDate] == NSOrderedAscending) return NO;
if ([date compare:endDate] == NSOrderedDescending) return NO;
return YES;
}
2. UITextView
改變字體的行間距
- (void)textViewDidChange:(UITextView *)textView {
/// 這句代碼的作用是, 如果輸入中文, 比如打出一個(gè) `好的`, 拼音為 `haode` ,這個(gè)時(shí)候從 h a o d e,
/// 打出來(lái)就開始計(jì)算行距了, 實(shí)際這個(gè)時(shí)候不應(yīng)該計(jì)算, 應(yīng)該等選中 `好的`這個(gè)詞以后在計(jì)算.
/// 這個(gè)屬性我理解意思是 當(dāng)有打出拼音有可以選擇的詞以后, 返回值就不為空了
if (textView.markedTextRange != nil) return;
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
paragraphStyle.lineSpacing = 8; /** 字體的行間距 */
NSDictionary *attributes = @{
NSFontAttributeName:[UIFont systemFontOfSize:15],
NSParagraphStyleAttributeName:paragraphStyle
};
textView.attributedText = [[NSAttributedString alloc] initWithString:textView.text attributes:attributes];
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者