1.textLabel字體居中
今天閑暇之余,發現了一個小問題,關于tableView中textLabel字體居中的問題。
設置tableViewCell的Style時設置為:UITableViewCellStyleDefault 然后碼農設置textLabel的字體居中時(NSTextAlignmentCenter),是沒有問題的,問題就是:你換成其他的Style試試,就不一樣了,即時你寫了代碼,也沒什么用。
cell.textLabel.textAlignment = NSTextAlignmentCenter;
重點在這里:想設置textLabel的字體居中就需要把cell的Style設置成UITableViewCellStyleDefault。
2.NSTimer創建:
+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(nullable id)userInfo repeats:(BOOL)yesOrNo;
這個方法創建NSTimer,需要手動添加到runloop中,但是不需要開啟,在添加到runloop之后,只要初始化時間間隔(TimeInterval)會自動開啟。
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)ti target:(id)aTarget selector:(SEL)aSelector userInfo:(nullable id)userInfo repeats:(BOOL)yesOrNo;
這個方法在創建完NSTimer之后,會自動添加到runloop中,但是需要手動開啟定時器:
- (void)fire;
關閉定時器:
- (void)invalidate;
如果其他小伙伴對我寫的這篇文章有什么異議,請盡快聯系我哦~ 方便我修改嘛