2013-06-03 128 views
0

首先我表示這樣的UIAlertView中在我的視圖控制器(實在沒有什麼花哨的話):UIAlertView中標題標籤奇怪的背景顏色問題

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Thank you" 
                 message:@"Successfully saved bookmark" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
[alert show]; 

但你可以在截圖中看到,標題標籤正在我認爲作爲其背景顏色的背景:

screenshot of UIAlertView

我還沒有的地方,這可能來自絲毫的想法,這裏是我怎樣稱呼我的視圖控制器出現時:

- (void)viewDidLoad 
{ 
    [super viewDidLoad];   
    // Do any additional setup after loading the view. 
    self.title = @"Details"; 

    [self.view styleBackgroundColor]; 

    [self.saveToBookmarks configureButtonStyle]; 
    [self.getDirections configureButtonStyle]; 

    self.name.text = [simoItem name]; 
    self.relativeLocation.text = [self relativeLocationStringForLocation:[simoItem location]]; 
    self.address.text = [simoItem address]; 
    self.type.text = [self buildTypesString]; 

    [self.name styleMainLabel]; 
    [self.address styleSubLabel]; 
    [self.type styleSubLabel]; 
    [self.relativeLocation styleSubLabel]; 
} 

試圖清理項目,卸載從SIM應用程序和震動着我的電腦,但沒有什麼迄今所做吧...

編輯:根據要求

-(void) styleMainLabel { 
    //colors 
    UIColor *backgroundColor = [Utilities getBackgoundColorPreference]; 
    UIColor *textColor = [Utilities getTextColorPreference]; 
    [self setBackgroundColor:backgroundColor]; 
    [self setTextColor:textColor]; 

    //text size styling 
    self.font = [UIFont fontWithName:@"Tiresias PCfont" size:35.0]; 
    self.adjustsFontSizeToFitWidth = YES; 
} 
+0

可以顯示styleMainLabel的代碼。 – Jitendra

+0

我覺得問題在這裏UIColor * backgroundColor = [Utilities getBackgoundColorPreference]; UIColor * textColor = [Utilities getTextColorPreference]; [self setBackgroundColor:backgroundColor]; [self setTextColor:textColor];請將其更改爲UIColor顏色名 – iEinstein

+0

好了我解決了這個問題,這是由於在輔助功能事件回調中設置了一些CALayer顏色屬性。感謝您的幫助 – chopchop

回答

0

好的我解決了這個問題,這是由於在可訪問事件回調中設置了一些CALayer顏色屬性。這裏是導致問題的代碼

- (void)accessibilityElementDidBecomeFocused { 
    [super accessibilityElementDidBecomeFocused]; 
    CALayer *layer = [self layer]; 
    layer.backgroundColor = [[Utilities getFocusedBackgroundColorPreference] CGColor]; 
} 

-(void) accessibilityElementDidLoseFocus { 
    [super accessibilityElementDidLoseFocus]; 
    CALayer *layer = [self layer]; 
    layer.backgroundColor = [[Utilities getBackgoundColorPreference] CGColor]; 
} 

我還沒有修復它,但關閉可訪問性使它消失。謝謝你的幫助。

0

styleMainLabel添加代碼styleMainLabel代碼可能存在問題。所以首先檢查你的代碼,如果你正在做的話,再次檢查你的代碼。

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Thank you" 
                 message:@"Successfully saved bookmark" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
[alert show]; 

UILabel *theTitle = [alert valueForKey:@"_titleLabel"]; 
    [theTitle setBackgroundColor:[UIColor clearColor]]; 
+0

謝謝,但它不工作...我嘗試setTextColor和seBackgroundColor在標題上具有相同的結果... – chopchop