Pet*_*r V 2 objective-c uibarbuttonitem ios
我已经调整了UIBarButtonItem以使用自定义字体和颜色属性
self.followButton = [[[UIBarButtonItem alloc]
initWithTitle: NSLocalizedString(@"TWITTER_FOLLOW_BUTTON_TEXT", nil)
style:UIBarButtonItemStylePlain
target:self
action:@selector(handleFollowButtonPressed:)]
autorelease];
Run Code Online (Sandbox Code Playgroud)
,
[self.followButton setBackgroundImage:[UIImage new] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Run Code Online (Sandbox Code Playgroud)
,
[followButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:@"Helvetica" size:14.0], UITextAttributeFont,nil] forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
和
NSDictionary *attributes = @{UITextAttributeTextColor : [UIColor colorWithRed:1 green:0.176 blue:0.333 alpha:1 /*#ff2d55*/ ]};
[followButton setTitleTextAttributes:attributes
forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
得到的外观
如何在不改变图像的情况下删除buttonitem的文本阴影?
将UIBarButtonItem's UITextAttributeTextShadowOffset属性设置为UIOffsetMake(0.0, 0.0).
你需要将它存储UIOffset在一个NSValue对象中:[NSValue valueWithUIOffset: UIOffsetMake(0.0, 0.0)].
| 归档时间: |
|
| 查看次数: |
1710 次 |
| 最近记录: |