Can somebody tell me please how can I move title of UITabBarItem for example 2px to top?
You can use tabbarItem.titlePositionAdjustment
to adjust.
In case you want to do much more with that then access tabbaritem subview and find label on tabbar.subviews
. For example
int i = 0;
for (NSObject *view in self.tabBar.subviews)
{
MTLog(@"%@", view);
if ([view respondsToSelector:@selector(subviews)])
{
for (NSObject *childView in ((UIView *)view).subviews)
{
if ([childView isKindOfClass:[UILabel class]])
{
if (i > (titlesArray.count - 1))
break;
UILabel *label = (UILabel *)childView;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:titlesArray[i] attributes:@{
NSFontAttributeName:[UIFont systemFontOfSize:9]
}];
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setMinimumLineHeight:26];
[style setAlignment:NSTextAlignmentRight];
[attributedString addAttribute:NSParagraphStyleAttributeName
value:style
range:NSMakeRange(0, attributedString.length)];
label.attributedText = attributedString;
i++;
}
}
}
}