gpt4 book ai didi

iphone - 使用 XIB 自定义 UIButton

转载 作者:可可西里 更新时间:2023-11-01 06:11:17 27 4
gpt4 key购买 nike

我知道可以使用 XIB 文件制作自定义 UITableViewCell 并执行此操作,但我如何使用 Button 执行此操作,因此制作新的标签或其他东西?

非常感谢

最佳答案

像这样实现 UIButton:

@interface MyNewButton : UIButton{
UILabel* nickNameLabel;
UIImageView* myImageView;
}

@property (nonatomic, retain) UIImageView *myImageView;
@property (nonatomic, retain) UILabel* nickNameLabel;
@end

@implementation MyNewButton
@synthesize myImageView;
@synthesize nickNameLabel;

- (id)initWithFrame:(CGRect)frame
{
myImageView=[[AXSImageView alloc] initWithFrame:CGRectMake(10, 3, 40, 40)];

[self addSubview:myImageView];
nickNameLabel=[[UILabel alloc] initWithFrame:CGRectMake(myImageView.frame.origin.x + myImageView.frame.size.width + 6, 15, 80, 17)];
[self addSubview:nickNameLabel];
}
- (void)drawRect:(CGRect)rect
{
//DO What You Need
}
- (void)dealloc
{

[nickNameLabel release],nickNameLabel=nil;
[myImageView release],myImageView=nil;
[super dealloc];
}
@end

使用 XIB 文件的 UIView 也可以作为 subview 添加到此类中,你知道什么意思:)

关于iphone - 使用 XIB 自定义 UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12769807/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com