嗨,大家好我是使用下面的代碼給UIAlertView.I自定義顏色使用S.D.K. 3.2.3和顏色正在變成所需的顏色。但今天我更新了我的S.D.K.現在我正在使用4.2.1,並在此S.D.K上運行此代碼。它工作。但是當我再次檢查AlertView的顏色沒有改變,但我提供的圖像的顏色,移動到alertview的後方。我不知道爲什麼會發生這種情況。 是否有任何問題,我不與ios 4.2一起工作。 只是讓我知道如何做到這一點在iOS 4.2代碼與3.2.3 sdk工作良好。 代碼是UIAlertView自定義顏色
UIAlertView *ForgotPassalert= [[UIAlertView alloc]initWithTitle:@"Status" message:@"An Email has sent to your Account Containing User Name and Password " delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"cancel",nil];
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0.0,
-120.0);
[ForgotPassalert setTransform: moveUp];
[ForgotPassalert show];
#pragma mark (AlertView Custom Color)
UIImage *theImage = [UIImage imageNamed:@"Untitled-1.png"];
theImage = [theImage stretchableImageWithLeftCapWidth:16 topCapHeight:16];
CGSize theSize = [ForgotPassalert frame].size;
UIGraphicsBeginImageContext(theSize);
[theImage drawInRect:CGRectMake(0, 0, theSize.width, theSize.height)];
theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[[ForgotPassalert layer] setContents:(id)theImage.CGImage];
//[[Passalert layer]setBackgroundColor:[[UIColor colorWithRed:179.0f/255.0f green:21.0f/255.0f blue:17.0f/255.0f alpha:1.0f]CGColor]];
[[ForgotPassalert layer]setCornerRadius:7.3F];
[ForgotPassalert release];
好吧,是的,我也在想同樣的。感謝 – Sabby 2010-12-06 04:07:07