Tag: 外观

IOS 5无法识别的select器在外观代理发送setBackgroundImage

就像很多开发者一样,我正在玩iOS 5的新function。 我试图使用外观代理来定制我的应用程序。 但在某些方法中,我得到一个错误。 这工作: [[UINavigationBar appearance] setBarStyle:UIBarStyleBlackTranslucent]; //and [[UINavigationBar appearance] setTintColor:[UIColor greenColor]]; 但是当我尝试: [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"toolbar_background.png"]]; 我得到一个无法识别的select器错误: -[_UIAppearance setBackgroundImage:]: unrecognized selector sent to instance 0x153020 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIAppearance setBackgroundImage:]: unrecognized selector sent to instance 0x153020' *** First throw call stack: (0x3107a8bf 0x3821f1e5 0x3107dacb 0x3107c945 0x30fd7680 0x2fe7 […]

我如何可以自定义borderWidth的所有UITextField外观?

我正在尝试为borderWith定制所有UITextField外观。 尝试这样的事情。 只有前两行有所作为。 其余的线路不工作? [[UITextField appearance] setBackgroundColor:[UIColor greenColor]]; [[UITextField appearance] setTextColor:[UIColor blackColor]]; [UITextField appearance].layer.cornerRadius = 6.0f; [UITextField appearance].layer.borderColor = [UIColor redColor].CGColor; [UITextField appearance].layer.borderWidth = 3.f;

iPhone的iOS UILabel如何自定义文本颜色的UITableView细节文本标签只?

我正在制作一个界面原型,并正在使用一个故事板来做到这一点。 部分原型涉及将UITableView单元格的详细UILabel设置为某种颜色。 我想避免在故事板中手动重新着色每个标签。 我发现我可以使用: [[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] setTextColor:[UIColor cyanColor]]; 改变tableview单元格中标签的外观。 有没有办法进一步完善这个代码只适用于详细tableview标签? 目前它改变了UITableViewCell的textLabel和detailTextLabel。 谢谢!

UIButton和外观的API – 支持与否?

根据UIAppearance协议的引用,一个类需要符合UIAppearanceContainer ,并支持标记为UI_APPEARANCE_SELECTOR方法,以使外观代理正常工作。 在苹果自己的指导video从WWDC 2011, “定制UIControls的外观” ,他们提供的例子,他们使用和讨论,UIButton和UILabel。 这两个类都符合UIAppearance和UIAppaeranceContainer协议(通过inheritanceUIView), 但是它们都没有标记为UI_APPEARANCE_SELECTOR方法。 虽然做的工作,但我的钱花在他们没有完全支持的苹果,为什么是不安全的使用外观代理对他们。 所以我有几个问题: 我错过了什么使UIButton / UILabel符合UIAppearance代理的先决条件? 你会认为与UIAppearance代理一起使用是不安全的吗? 如果事实certificate这两个类不符合(当然,显而易见的答案是使用UI_APPEARANCE_SELECTOR标记其方法并符合UIAppearance协议的任何对象),那么您将在生产中使用外观代理?

UIAppearance不会对以编程方式创build的UILabels生效

我们已经扩展了UILabel,以便能够在我们的应用程序中为给定标签types的所有用途应用标准字体和颜色。 例如。 @interface UILabelHeadingBold : UILabel @end 在我们的AppDelegate中,我们应用这样的字体和颜色 [[UILabelHeadingBold appearance] setTextColor:<some color>]; [[UILabelHeadingBold appearance] setFont:<some font>]; 在我们的XIB中添加一个UILabel时,我们现在可以select类为UILabelHeadingBold的类,并且按照预期工作。 标签显示正确的字体和颜色,在我们的AppDelegate中指定。 但是,如果我们以编程方式创build标签,例如。 UILabelHeadingBold *headingLabel = [[UILabelHeadingBold alloc] initWithFrame:CGRectMake(10, 10, 100, 30)]; [self.mainView addSubview:headingLabel]; UILabel没有得到应用的预期的字体/颜色。 我们必须手动应用这些属性。 有没有办法使UIAppearance能够在编程创build的UI元素上生效,还是只能在XIB中使用时才起作用?

UINavigationBar和新的iOS 5 +外观API – 如何提供两个背景图像?

我想利用新的iOS 5外观API为我的应用程序中的所有UINavigationBar实例提供自定义背景图像。 要做到这一点,就像这样简单: [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"whatever.png"] forBarMetrics:UIBarMetricsDefault]; 但是,对于每个实例,我想根据translucent属性的值提供不同的图像,例如 // For UINavigationBar instances where translucent returns YES: [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"whatever-translucent.png"] forBarMetrics:UIBarMetricsDefault]; // Otherwise: [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"whatever.png"] forBarMetrics:UIBarMetricsDefault]; 鉴于外观API似乎使用类方法configuration,是这样的可能吗?