UIButton with IB_DESIGNABLE throws runtime attribute warning and does not render in Interface Builder

前端 未结 7 654
耶瑟儿~
耶瑟儿~ 2021-01-30 12:59

I\'m running Xcode 6.1 and I have been using IB_DESIGNABLE with IBInspectable for quite a few projects already but all of the sudden it just doesn\'t work anymore. I have create

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 13:38

    Try changing your "CGFloat" declaration for spacingBetweenLabelAndImage into "NSNumber".

    As far as I know, you can't call "setValue:" on a C-type variable.

    Changing the declaration of "spacingBetwenLabelAndImage" to NSNumber would also require you to change a bit of code too:

    CGFloat halfSpacing = self.spacingBetweenLabelAndImage == 0 ? 0 : self.spacingBetweenLabelAndImage / 2;
    

    might become something like:

    CGFloat halfSpacing = (self.spacingBetweenLabelAndImage ? ([self.spacingBetweenLabelAndImage floatValue] / 2) : 0.0);
    

    (I'm not 100% certain if this is a perfect translation of the first line, but I wanted to show how to get a floatValue out of a NSNumber)

提交回复
热议问题