我知道可以使用 XIB 文件制作自定义 UITableViewCell 并做到了这一点,但是我如何使用按钮来做到这一点,所以制作新的标签或其他东西?
非常感谢你
最佳答案
像这样实现 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 添加到这个类中,你知道什么意思:)