navigation和tabbar上的文字.图片 自定义

[[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor blackColor],UITextAttributeFont:[UIFont fontWithName:@"Marion-Italic" size:14.0]}           forState:UIControlStateNormal];

UIControState的设置:

UIControlStateNormal:未被选中时;

UIControlStateHighlighted:被选中的时候;

navigation和tabbar上的文字.图片

 [self.navigationController.tabBarItem setTitlePositionAdjustment:UIOffsetMake(15, -10)];

 uitabbaritem.imageInsets

// 导航底部线条颜色

[self.navigationController.navigationBar setBackgroundImage:[self imageWithColor:[UIColor clearColor]]

forBarPosition:UIBarPositionAny

barMetrics:UIBarMetricsDefault];

[self.navigationController.navigationBar setShadowImage:[UIImage new]];

// 去除tabbar顶部黑线

  1.

  CGRect rect = CGRectMake(0, 0, SCREEN_WIDTH, tabbarVC.view.frame.size.height);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);

CGContextFillRect(context, rect);

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

[tabbarVC.tabBar setBackgroundImage:img];

[tabbarVC.tabBar setShadowImage:img];

  2.

    tabbarVC.tabBar.barStyle                    = UIBarStyleBlack;

    tabbarVC.tabBar.translucent                 = YES; // 这句话是加透明效果的。

// 返回一张纯色图片

- (UIImage *)imageWithColor:(UIColor *)color

{

CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);

UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextSetFillColorWithColor(context, [color CGColor]);

CGContextFillRect(context, rect);

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return image;

}

上一篇:转载:C++中两个类中互相包含对方对象的指针问题


下一篇:BZOJ 2716 [Violet 3]天使玩偶 ——KD-Tree