我试图使用swift更改XCode中的视图控制器中的标签栏颜色.我有一个十六进制,我匹配RGB值,我试图在此代码中设置它.(哪个不起作用)
let color = UIColor(red: 41, green: 40, blue: 39, alpha: 1.0)
UITabBar.appearance().barTintColor = color
Run Code Online (Sandbox Code Playgroud)
但是这段代码确实:
UITabBar.appearance().barTintColor = UIColor.whiteColor()
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释为什么这不起作用,我能做些什么来解决它?
我正在编写一个应用程序,我需要实现的功能之一要求应用程序从网站提取JSON数据,将其存储在字典中,然后能够使用所有键并显示值.我不知道字典的结构是什么样的,所以我希望以递归方式遍历字典来检索所有信息.
我将JSON存储在我需要的网站的字典中,当我将字典变量放在println()语句中时,它会正确显示.
我发现这个链接,我认为这个,或者这个的一些变化应该有效,但我仍然相当新的swift,我不确定这是如何从Objective-c转换为swift.
我感兴趣的链接部分是这样的:
(void)enumerateJSONToFindKeys:(id)object forKeyNamed:(NSString *)keyName
{
if ([object isKindOfClass:[NSDictionary class]])
{
// If it's a dictionary, enumerate it and pass in each key value to check
[object enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
[self enumerateJSONToFindKeys:value forKeyNamed:key];
}];
}
else if ([object isKindOfClass:[NSArray class]])
{
// If it's an array, pass in the objects of the array to check
[object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
[self enumerateJSONToFindKeys:obj forKeyNamed:nil];
}];
}
else
{
// If we …Run Code Online (Sandbox Code Playgroud)