Created
June 22, 2012 02:45
-
-
Save ttsubono/2969889 to your computer and use it in GitHub Desktop.
iOS4でNavigationBar上のボタン色をダイナミックに変える
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (UIView *view in self.navigationController.navigationBar.subviews) { | |
if ([[[view class] description] isEqualToString:@"UINavigationButton"]) { | |
[(UINavigationButton *)view setTintColor:newColor]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
・iOS5ではUIBarButtonItemにtintColorプロパティがある
・UINavigationButtonは非公開なので、isKindOfClassではなくisEqualToStringにしている
・NavigationBarにボタンが複数あると、全てのボタン色がかわる(ただし、戻るボタンには適用されない)