iOS set background color for all viewcontroller self.view's

前端 未结 4 429
既然无缘
既然无缘 2021-01-04 01:39

Is there a way to set same background image for all views?

Setting same background in all viewDidLoad: methods. It\'s not cool.

4条回答
  •  猫巷女王i
    2021-01-04 02:12

    I don't think this is a good idea, but if you really want to do this, you could do something like this:

    - (void)setBGColor:(UIColor *)color forAllSubviewsOf:(UIView *)view
    {
        [view setBackgroundColor:color];
        for (UIView *sub in view.subviews)
            [self setBGColor:color forAllSubviewsOf:sub];
    }
    

提交回复
热议问题