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