I'm new to programming and Stackoverflow, so I don't have enough reputation to comment directly to deploy https://stackoverflow.com/users/4673064/daniel-tseng an excellent answer. So I have to write my new answer, and it is like this:
extension UIButton { func setTitleWithoutAnimation(_ title: String?, for controlState: UIControlState) { UIView.performWithoutAnimation { self.setTitle(title, for: controlState) self.layoutIfNeeded() } } }
Works great except for:
If all my subsequent calls in the "setTitleWithoutAnimation" code do not indicate the sender, then I get these strange messages related to CoreMedia or CoreData, for example, "Failed to inherit CoreMedia permissions from 2526: (null)"
This is probably quite the basis for coding and iOS, but for me, as a new coder, he sent me on a rabbit path for a while, like in: Today, the extension failed to inherit CoreMedia permissions , from where people had interesting answers, but it’s NOT reach the root of my problem.
So, I finally found that I need to go through all the parameters of my function without parameters, that is, I needed to specify the sender. This sender can be UIButton, Any, or AnyObject. It all worked, but in the end, there is a conflict between adding the button extension with "self" and the subsequent concrete expression that the button uses it.
Again, perhaps the main one, but new to me, so I decided it was worth sharing.
Ian Hanson Apr 05 '18 at 22:39 2018-04-05 22:39
source share