iOS系统navigationBar背景色,文字颜色处理

- (void)setRightBarButtonItem
{
    // Create done Button
    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc]initWithTitle:[NSString stringWithFormat:@"确定(%lu/%lu)", (unsigned long)self.selectedAssetURLs.count, (unsigned long)self.maximumNumberOfSelection] style:UIBarButtonItemStylePlain target:self action:@selector(done:)];

    [self.navigationItem setRightBarButtonItem:doneButton animated:YES];

    UIColor *color = [UIColor colorWithHexString:@"#fe5346"];
    CGRect frame = CGRectMake(0, 0, SCREEN_WIDTH, 64);
    UIImage *image = [UIImage imageWithColor:color withFrame:frame];
    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.tintColor    = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName : [UIColor whiteColor]};

}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    /**
     *  @author SongXing, 15-07-30 14:07:45
     *
     *  UIIMagePickerController颜色修正
     *
     */
    if ([navigationController isKindOfClass:[UIImagePickerController class]] &&
        ((UIImagePickerController *)navigationController).sourceType ==     UIImagePickerControllerSourceTypePhotoLibrary) {
        [[UIApplication sharedApplication] setStatusBarHidden:NO];
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];
    }

    if (navigationController.viewControllers.count != 3) return;

    CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height;

    UIView *plCropOverlay = [viewController.view.subviews[1] subviews][0];

    plCropOverlay.hidden = YES;

    int position = 0;

    position = (screenHeight == 568) ? 124 : 80;

    CAShapeLayer *circleLayer = [CAShapeLayer layer];

    UIBezierPath *path2 = [UIBezierPath bezierPathWithOvalInRect:
                           CGRectMake(0.0f, position, SCREEN_WIDTH, 320.0f)];
    [path2 setUsesEvenOddFillRule:YES];

    [circleLayer setPath:[path2 CGPath]];

    [circleLayer setFillColor:[[UIColor clearColor] CGColor]];
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_WIDTH, screenHeight-72) cornerRadius:0];

    [path appendPath:path2];
    [path setUsesEvenOddFillRule:YES];

    CAShapeLayer *fillLayer = [CAShapeLayer layer];
    fillLayer.path = path.CGPath;
    fillLayer.fillRule = kCAFillRuleEvenOdd;
    fillLayer.fillColor = [UIColor clearColor].CGColor;
    fillLayer.opacity = 0.8;
    [viewController.view.layer addSublayer:fillLayer];

}
时间: 2024-12-06 13:57:42

iOS系统navigationBar背景色,文字颜色处理的相关文章

iOS搜索时状态栏文字颜色修改

问题1:使用UISearchDisplayController搜索时状态栏变黑 解决方案:参考参考文献1的方法将导航控制器的view的背景改为[self.navigationController.view setBackgroundColor:[UIColor whiteColor]];或者搜索条的颜色 问题2:问题1的解决方案可能会导致在iPhone5s上搜索时字体为白色,导致看不清楚状态栏上的时间.电量 解决方案:实现UISearchDisplayDelegate里的两个方法,将要搜索时将状

iOS开发-修改状态栏文字颜色

首先targets-->info -->设置UIViewControllerBasedStatusBarAppearance 为NO 然后在需要改变状态栏颜色的 AppDelegate中在 didFinishLaunchingWithOptions 方法中增加: [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 只要这两步  搞定!

自定义iOS导航栏背景,标题和返回按钮文字颜色-----转载自gyz413977349

在iOS7下,默认导航栏背景,颜色是这样的,接下来我们就进行自定义,如果你仅仅是更改一下背景和颜色,代码会很简单,不需要很复杂的自定义View来替代leftBarItem 更改导航栏的背景和文字Color 方法一: [objc] view plaincopy //set NavigationBar 背景颜色&title 颜色 [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:20/255.

CSS 实现背景色渐变和文字颜色渐变

1. 背景色渐变 A . linear-gradient:用线性渐变创建图像. 语法:<linear-gradient> = linear-gradient([ [ <angle> | to <side-or-corner> ] ,]? <color-stop>[, <color-stop>]+) 下述值用来表示渐变的方向,可以使用角度或者关键字来设置: <angle>:用角度值指定渐变的方向(或角度). to left: 设置渐变为

android TextView 设置部分文字背景色和文字颜色

通过SpannableStringBuilder来实现,它就像html里边的<span>元素改变指定文字的文字颜色或背景色 public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Str

自定义iOS导航栏背景,标题和返回按钮文字颜色

一.导航栏的背景和文字Color: 方法一: //设置NavigationBar 背景颜色&title 颜色 [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:20/255.0 green:155/255.0 blue:213/255.0 alpha:1.0]]; [self.navigationController.navigationBar setTitleTextAttributes

iOS不得姐项目--登录模块的布局,设置文本框占位文字颜色,自定义内部控件竖直排列的按钮

一.登录模块的布局 将一整部分切割成若干部分来完成,如图分成了三部分来完成 设置顶部状态栏为白色的方法 二.设置文本框占位文字颜色 <1>方法一与方法二实现原理是同一种,都是通过设置placeholder的NSAttributeString来设置文字属性 方法二效果图: <2>第三种方法是通过RunTime找到隐藏的可以设置placeholder颜色的属性,通过KVC来赋值.RunTime会单独拿出来讲 三.按钮自定义,重新排列子控件的排列位置

修改状态栏的文字颜色和背景色

一.修改状态栏文字颜色 这里修改文字颜色分两种情况 (1)导航栏是隐藏状态 如果导航栏为隐藏状态 可以直接在控制器中重写如下方法 // 重写方法 状态栏白色 - (UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent; } 这样状态栏的文字就可以变成白色了 (2)导航栏不是隐藏状态 如果导航栏不是隐藏状态 会发现方法(1)没有作用了这时要采用第二种方法, 一共有两个步骤1 -> 设置info.p

iOS利用storyboard修改UITextField的placeholder文字颜色

最近有个需求需要修改UITextField的placeholder文字颜色,在网上找发现有用代码修改的,但是考虑到更加优雅的实现,所以尝试着在storyboard中直接实现,结果竟然真的成功了(原谅我太小白),实现的位置如下: 具体步骤: 1.在User Defined Runtime Attributes中添加一个Key. 2.输入Key Path(这里我们输入_placeholderLabel.textColor). 3.选择Type,有很多种(这里我们选择Color) 4.设置Value(