【问题标题】:How do I write custom color coding?如何编写自定义颜色编码?
【发布时间】:2013-12-26 07:40:51
【问题描述】:

我在 viewDidLoad 方法中为我的 UserCreationViewController

使用此代码
NSDictionary *textAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                [UIColor greenColor],NSForegroundColorAttributeName,
                                [UIColor blackColor],NSBackgroundColorAttributeName,nil];

self.navigationController.navigationBar.titleTextAttributes = textAttributes;
self.title = @"User Creation";

我想知道的是,我知道我可以将 UIColor 更改为 redColor、yellowColor(等),我该如何编写自定义的“颜色井”颜色。

换句话说如果此导航栏标题为从颜色井中挑选的自定义颜色,我该如何设置颜色?

【问题讨论】:

    标签: objective-c ios7 xcode5


    【解决方案1】:

    您可以使用以下代码:

    UIColor *customColor = [UIColor colorWithRed:155.0/255.0 green:10.0/255.0 blue:50.0/255.0 alpha:1.0];
    

    UIColor *customColor = [UIColor colorWithHue: 0.667 saturation: 1.0 brightness: 1.0 alpha: 1.0];
    

    More info.

    【讨论】:

    • 我想出了第一行代码,但谢谢你的第二行,不知道那个。我会在你的时间里给你答案。
    猜你喜欢
    • 1970-01-01
    • 2020-02-10
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多