UIButton doesn't listen to content mode setting?

后端 未结 16 2145
情话喂你
情话喂你 2020-12-02 08:45

firstButton is a UIButton of type Custom. I\'m programmatically putting three of them across each cell of a table, thusly:

[firstButton setImage:markImage fo         


        
16条回答
  •  孤城傲影
    2020-12-02 09:14

    In trying to figure this out, my method got a bit hackier as time went on, and I wound up subclassing UIButton and overriding setHighlighted:

    For me it works to just knock down the image alpha to .5, because they're on a black background.

    However, it only works if I comment out [super setHighlighted:] (where it appears the image-stretchy code is going on), which just doesn't feel like the right way to solve this at all...everything seems to be working fine, though. We'll see how it holds up as I keep working on it.

    - (void)setHighlighted:(BOOL)highlight {
        if (highlight) {
            [self.imageView setAlpha:.5];
        }  else {
            [self.imageView setAlpha:1];        
        }
    
    //    [super setHighlighted:highlight];
    }
    

提交回复
热议问题