0

首先,我在我的视图控制器中显示这样的 UIAlertView(真的没有什么花哨的):

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

但正如您在屏幕截图中看到的那样,标题标签将我的视图的背景作为其背景颜色:

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 中卸载应用程序并摇动我的电脑,但到目前为止还没有完成...

styleMainLabel编辑:应要求添加代码

-(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;
}
4

2 回答 2

0

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]];
于 2013-06-03T07:32:57.653 回答
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];
}

我还没有修复它,但关闭可访问性使它消失了。谢谢你的帮助。

于 2013-06-03T07:42:54.897 回答