2
我正在寫一個帶有漸變圖像背景的標籤的iPad應用程序。這已經在4.2,但它不再工作。每次我嘗試運行時,無論我處於4.2還是4.3,我都會得到SIGABRT。我將把下面的代碼放在下面,我會很感激任何幫助。謝謝。當調用'UIColor colorWithPatternImage'時阻止iOS SIGABRT
LabelSingAvg = [[UILabel alloc] initWithFrame:CGRectMake(70, -300, 200, 800)];
LabelSingAvg.text = @"99.8";
LabelSingAvg.font = [UIFont systemFontOfSize:90];
UIImage *myGradient = [UIImage imageNamed:@"textGradient.png"];
//Line that causes SIGABRT below:
LabelSingAvg.textColor = [UIColor colorWithPatternImage:myGradient];
LabelSingAvg.backgroundColor = [UIColor clearColor];
LabelSingAvg.textAlignment = UITextAlignmentCenter;
LabelSingAvg.adjustsFontSizeToFitWidth = YES;
LabelSingAvg.layer.shadowOpacity = .5;
LabelSingAvg.layer.shadowRadius = 4.0;
LabelSingAvg.layer.shadowColor = [UIColor blackColor].CGColor;
LabelSingAvg.layer.shadowOffset = CGSizeMake(1.0, 1.0);
//LabelSingAvg.alpha = 0.8;
[self.view addSubview:LabelSingAvg];
你確定'myGradient'不是'nil'嗎? – FreeAsInBeer 2011-03-30 13:23:53
嗯,我認爲,你的圖像是零...無論如何,它可能會被釋放(我真的懷疑),在這種情況下,嘗試寫在一行; p [[UIColor colorWithPatternImage:[ UIImage imageNamed:@「textGradient.png」]];' – Lepidopteron 2011-03-30 13:32:33
請你可以發佈崩潰的調試器堆棧跟蹤? – 2011-03-30 13:51:12