How to prevent UIButton from flashing when updating the title

前端 未结 9 1134
旧巷少年郎
旧巷少年郎 2021-01-30 04:41

When I call setTitle on a UIButton, the button flashes in iOS 7. I tried setting myButton.highlighted = NO, but that didn\'t stop the button from flashing.

[myBu         


        
9条回答
  •  甜味超标
    2021-01-30 05:36

    *Please note *

    when "buttonType" of _button is "UIButtonTypeSystem", below code is invalid

    [UIView setAnimationsEnabled:NO];
    [_button setTitle:@"title" forState:UIControlStateNormal];
    [UIView setAnimationsEnabled:YES];
    

    when "buttonType" of _button is "UIButtonTypeCustom", above code is valid.

提交回复
热议问题