Modify UIImage renderingMode from a storyboard/xib file

前端 未结 16 2362
别那么骄傲
别那么骄傲 2020-12-02 08:00

Is it possible to modify a UIImage\'s renderingMode from a storyboard or xib editor?

The goal is to apply tintColor to the par

16条回答
  •  情书的邮戳
    2020-12-02 08:38

    It's very easy to fix

    Just create class UIImageViewPDF and use it in your storyboard

    IB_DESIGNABLE
    @interface UIImageViewPDF : UIImageView
    
    @end
    
    @implementation UIImageViewPDF
    
    - (void) didMoveToSuperview
    {
        [super didMoveToSuperview];
        self.image = [self.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        id color = self.tintColor;
        self.tintColor = color;
    }
    
    @end
    

提交回复
热议问题