English 中文(简体)
接口生成器中的自定义字符串属性
原标题:Custom string properties in interface builder

有没有一种简单的方法可以公开类的NSString或UIColor属性,以便在接口生成器中修改它们?

这将非常有用,例如,将颜色属性添加到自定义视图(然后以编程方式使用),以便在界面生成器中适当地对其进行操作。

最佳回答

这篇来自Cocoa with Love的文章描述了如何使用界面生成器插件进行Mac开发。不幸的是,目前无法将IBPlugins与iPhone SDK一起使用(请注意接口生成器插件编程指南仅出现在Mac OS X文档中,而非iOS文档中)。

问题回答

在iOS 8中,添加了两个新属性,@IBInspectable和@IBDesignable。这是一篇完整的文章。

http://www.weheartswift.com/make-awesome-ui-components-ios-8-using-swift-xcode-6/

没有办法添加自定义的“非IBOutlet”属性,但我建议您添加一个UILabel来利用它的文本属性,当然,当加载视图时会释放它。





相关问题
How do you create UIBarButtonItems with a radio interface?

I have a UIToolbar that needs three buttons in a radio style, meaning that of the three, only one button can be pushed at a time. The documentation makes reference to the possibility of setting up ...

iPhone settings bundle

I want to allow the user to enter a valid date using the iPhone’s settings application. I have experimented with many of the PreferenceSpecifiers data node types including date. I have two issues: ...

Circular #import/@class problem in ObjectiveC

I m going to use an example to properly illustrate my confusion. I can t quite wrap my head around this. In Cocoa touch, we have UIViewController and its subclass, UINavigationController. Now, UIVC ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Cocoa-Touch: issue looping MPMoviePlayerController

I have an app which has to load some data at startup, so I want to display a splash-screen animation. I m using the MPMoviePlayerController to play a m4v file. The movie has it s background set to [...

Iphone sequential animation with setAnimationDelay

I m trying to chain animation events. The application I m coding for work has a multiple choice quiz. First you pick your multiple choice answer. The quiz view fades away. Then a label ("correct" or "...

热门标签