Date
Sep. 8th, 2024
 
2024年 8月 6日

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.
反曲点科技创始人和首席执行官。
程序猿、设计师、奇怪的博主。
苹果死忠、热爱色彩斑斓的世界。
如有意向请随时 与我联系