开发者

How can i create a my own custom button without using interface builder? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I want to create my own custom button without using any interface builder.

Actually i wants to set all my properties/attribute(Like frame,color,size,label etc.) separate in a NSObject class.Then from my UIView class i want to draw them .

How can开发者_如何转开发 i do it as i am never use NSObject class?

Any sample application or example to do this?


Actually, you can subclass UIButton - for an example, have a look at Fun With UIButtons and Core Animation Layers. Is this is too much, you can simply create a new UIButton and set it's properties:

UIButton *btn = [[UIButton alloc] initWithFrame:yourFrame]
btn.backgroundColor = [UIColor redColor];
...
[btn release;]


Check this Code:

    UIButton *btn=[[UIButton alloc] initWithFrame:CGRectMake(152,0,150,128)];       
    [btn setBackgroundColor:[UIColor clearColor]];
    [btn setImage:actualImage forState:UIControlStateNormal];   
    [btn setTag:1];
    [btn addTarget:self action:@selector(btnTouched:)forControlEvents:UIControlEventTouchDown];
    [self addSubview:btn];
    [btn release];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜