小编Tat*_*yak的帖子

生成随机UIColor

我尝试为UILabel获得随机颜色......

- (UIColor *)randomColor
{
    int red = arc4random() % 255 / 255.0;
    int green = arc4random() % 255 / 255.0;
    int blue = arc4random() % 255 / 255.0;
    UIColor *color = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
    NSLog(@"%@", color);
    return color;
}
Run Code Online (Sandbox Code Playgroud)

并使用它:

[mat addAttributes:@{NSForegroundColorAttributeName : [self randomColor]} range:range];
Run Code Online (Sandbox Code Playgroud)

但颜色总是黑色的.怎么了?

PS抱歉我的英文)

objective-c uicolor

19
推荐指数
6
解决办法
2万
查看次数

Firebase缓存过期始终与调试模式一样

我正在尝试在我的iOS应用中实施Firebase远程配置.一切正常,但有一个问题 - 远程配置总是从firebase服务器获取数据,而不是从缓存中获取数据.我尝试过很多变种而没有任何成功.这是我的代码:

+ (instancetype)sharedInstance
{
static ConfigManager *_sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    _sharedInstance = [[self alloc] init];

});
return _sharedInstance;
}

-(instancetype)init
{
self = [super init];
if (self) {
    self.remoteConfig = [FIRRemoteConfig remoteConfig];
    [self updateRemoteConfig];
}
return self;
} 

- (void)activateDebugMode
{
FIRRemoteConfigSettings *remoteConfigSettings = [[FIRRemoteConfigSettings alloc] initWithDeveloperModeEnabled:YES];
self.remoteConfig.configSettings = remoteConfigSettings;
}

- (void)updateRemoteConfig
{
[self fetchConfigWithCompletionHandler:nil];
}

- (void)fetchConfigWithCompletionHandler:  (FireBaseConfigCompletionHandler)completionHandler
{
NSTimeInterval cacheExpiration = 43200;
BOOL debug = ConfigurationValue(DebugMode);
if (debug) {
    cacheExpiration = …
Run Code Online (Sandbox Code Playgroud)

objective-c ios firebase firebase-remote-config

6
推荐指数
1
解决办法
471
查看次数