When changing UIBarButtonItem title, the transition is jerky/flickers

吃可爱长大的小学妹 提交于 2019-12-05 00:33:40
user3860421

Instead of setting the title again, you could set the button again with the title and then animate it:

(void)setRightBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated

Another solution would be to change the title without animations.

[UIView performWithoutAnimation:^{
    self.navigationItem.rightBarButtonItem.title = @"Mellansvår";
}];

You can skip the animation altogether, if you change the UIBarButtonItem title while it is not attached to the navigationItem, like this:

UIBarButtonItem *tempItem = self.navigationItem.rightBarButtonItem;
self.navigationItem.rightBarButtonItem = nil;
tempItem.title = @"Mellansvår";
self.navigationItem.rightBarButtonItem = tempItem;

The animation will disappear completely, but the visual effect looks way better IMHO.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!