Open itsaboutcode opened 9 years ago
I don't know if this answers your question but yesterday I implemented something similar with IonIcons on a UIBarButtonItem - the approach may work with FontAwesome - where you create an image, apply it to a UIButton and then set the UIBarButtonItem with a custom view -> the UIButton
UIImage *plusIcon = [IonIcons imageWithIcon:ion_ios_plus_outline
size:25.0
color:self.theme.colorTextNavBar];
UIButton *plusButton = [UIButton buttonWithType:UIButtonTypeCustom];
plusButton.frame = CGRectMake(0, 0, plusIcon.size.width * 3, plusIcon.size.height);
[plusButton setImage:plusIcon forState:UIControlStateNormal];
[plusButton setTitle:@"Favs" forState:UIControlStateNormal];
[plusButton setTintColor:self.theme.colorTextNavBar];
[plusButton setTitleColor:self.theme.colorTextNavBar forState:UIControlStateNormal];
[plusButton centerButtonAndImageWithSpacing:4];
[plusButton addTarget:self action:@selector(favoriteButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *plusBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:plusButton];
self.navigationItem.rightBarButtonItem = plusBarButtonItem;
-(void) centerButtonAndImageWithSpacing:(CGFloat)spacing {
self.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, spacing);
self.titleEdgeInsets = UIEdgeInsetsMake(0, spacing, 0, 0);
}
As you can see, most of the properties were applied to the UIButton. I haven't tried this with FontAwesome but as long as you have an image, this approach should do the trick. I hope this helps you.
I don't understand your question, what kind of properties you're going to change?
@robmontesinos - Sorry for the late reply. Thanks for your reply, that helps.
Hi,
I was wondering if there is any workaround/hack to change the properties when used them as UIBarButtonItem?
Thanks.