Accessing View in awakeFromNib?

前端 未结 5 609
醉话见心
醉话见心 2020-12-08 08:48

I have been trying to set a UIImageView background color (see below) in awakeFromNib

[imageView setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alp         


        
5条回答
  •  無奈伤痛
    2020-12-08 09:19

    I believe your call to super needs to be the first line in the awakeFromNib method, otherwise the elements won't be setup yet.

    -(void)awakeFromNib {
      [super awakeFromNib];
      [imageView setBackgroundColor:[UIColor colorWithRed:0 green:0 blue:0 alpha:1.0]];
      [testLabel setText:@"Pants ..."];  
    }
    

提交回复
热议问题