【发布时间】:2012-02-11 18:56:29
【问题描述】:
方法声明,
-(UILabel *)returnUILabel:(UILabel *)myLabel color:(UIColor *)labelColor x:(int)xParameter y:(int)yParamater width:(int)widthParameter height:(int)heightParameter
{
CGRect cellFrame = CGRectMake(xParameter, yParamater, widthParameter, heightParameter);
myLabel = [myLabel initWithFrame:cellFrame];
myLabel.text = @"Testing";
myLabel.shadowOffset = CGSizeMake(1,1);
myLabel.backgroundColor = labelColor;
return myLabel;
}
在 viewDidLoad 中调用如下,
UILabel *myLabel = [[UILabel alloc] init];
UIColor *labelColor = [UIColor redColor];
[self.view addSubview:[self returnUILabel:myLabel color:labelColor x:17 y:260 width:140 height:130]];
labelColor = [UIColor yellowColor] ;
[self.view addSubview:[self returnUILabel:myLabel color:labelColor x:170 y:260 width:140 height:130]];
[super viewDidLoad];
在我看来,我只看到黄色标签,而我应该看到一个红色和一个黄色。为什么 ??。
同样的方法适用于UIImageView。
谢谢
【问题讨论】:
标签: objective-c uilabel