imageView contentMode を に設定すると、UIButton イメージに問題が発生しますUIViewContentModeScaleAspectFill
。
UIButton *imageButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 200, 100)];
imageButton.imageView.contentMode = UIViewContentModeScaleAspectFill;
[imageButton setImage:[UIImage imageNamed:@"myImage.jpg"] forState:UIControlStateNormal];
[imageButton addTarget:self action:@selector(doSmth:) forControlEvents:UIControlEventTouchUpInside];
ボタン内の画像は、ボタン領域全体を埋めるように適切にスケーリングされます。
ボタンをクリック/タッチすると、 contentMode が に設定されている場合のように、画像のサイズが変更されます (ちらつき) UIViewContentModeScaleAspectFit
。
クリック/タッチが発生したときにこのちらつきを取り除く方法を知っている人はいますか?
ありがとう!