Date
Nov. 21st, 2024
 
2024年 10月 21日

Post: iOS Waring: TabBar Item States

iOS Waring: TabBar Item States

Published 12:09 Sep 19, 2015.

Created by @ezra. Categorized in #Programming, and tagged as #iOS.

Source format: Markdown

Table of Content

在设置 TabBar 文字属性时,可能会遇到类似这样的警告:

button text attributes only respected for UIControlStateNormal, UIControlStateHighlighted and UIControlStateDisabled. state = 4 is interpreted as UIControlStateHighlighted.

这可能是因为你写了这样的代码:

UIBarButtonItem *item = [UIBarButtonItem appearance];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateSelected];

注意上述代码中使用了 UIControlStateSelected 这个状态,但警告中已经说明,在该情境中 按下状态 被认为是 UIControlStateHighlighted,因此我们只需要修改这个状态即可。

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
开发、设计与写作皆为所长。
热爱苹果、钟情色彩。
随时恭候 垂询