UIBarButtonItem-Badge
UIBarButtonItem-Badge copied to clipboard
iOS 9 makes the badge a square?
UIBarButtonItem-Badge was working fine in iOS 8 but after upgrading to iOS 9 and Swift 2.0 the badge now shows up as a square. Anyone know a fix?
+1
I found the solution! I don't understand why, but in iOS 9 we need to update frame after layer... In the end of function "updateBadgeFrame" use this code:
self.badge.layer.cornerRadius = (minHeight + padding) / 2;
self.badge.layer.masksToBounds = YES;
self.badge.frame = CGRectMake(self.badgeOriginX, self.badgeOriginY, minWidth + padding, minHeight + padding);
I've fixed this bug. https://github.com/mikeMTOL/UIBarButtonItem-Badge/pull/15
ok this my code with fix ios9 bug (好啦!我修复这个bug啦,我是不是很牛逼?哈哈哈,其实顺序改一下,就行了)
self.badge.layer.masksToBounds = YES; self.badge.layer.cornerRadius = (minHeight + padding) / 2; self.badge.frame = CGRectMake(self.badgeOriginX, self.badgeOriginY, minWidth + padding, minHeight + padding);
It worked. Thanks :+1:
+1
+1
add in badge's lazy getter. So it will be working on iOS 9.2. Without it doesn't work lbl.clipsToBounds = YES;
+1
I'm running 9.2 and still see the label squared. Even after lbl.clipsToBounds = YES; On launch it kinda changes from circular to squared, I can see that it has some strange visual effect. Trying to solve it.
+1