开发者

IOS: Create a reusable UI widget that can be used in Interface Builder?

开发者 https://www.devze.com 2023-02-16 04:07 出处:网络
IOS: Create a reusable UI widget that can be used in Inte开发者_运维问答rface Builder?How do you create an element that can be used in other forms?All you need to do is make a subclass of your object,

IOS: Create a reusable UI widget that can be used in Inte开发者_运维问答rface Builder? How do you create an element that can be used in other forms?


All you need to do is make a subclass of your object, let's say UIButton for instance.

Custom Object:

@interface MyCustomButton : UIButton 
{
    UIColor *tintColor;
}
@property (nonatomic,retain) UIColor *tintColor;
@end

Your Class:

#import "MyCustomButton.h"
@interface MyViewController : UIViewController
{
    IBOutlet MyCustomButton *myButton;
}
@property (nonatomic,retain) MyCustomButton *myButton;
@end

Now in interface Builder, add a UIBUtton and you can connect it to your custom myButton.


I think you mean Interface Builder instead of UIBuilder and something close to what you are looking for is here

http://cocoawithlove.com/2009/07/custom-views-in-interface-builder-using.html

but it doesn't work on iOS.

0

精彩评论

暂无评论...
验证码 换一张
取 消