Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drawing a circle UIButton performance

I am currently doing it the following:

  self.userProfileButton.layer.borderColor=[UIColor whiteColor].CGColor;
    self.userProfileButton.layer.borderWidth=1.5f;
    self.userProfileButton.layer.cornerRadius = 25;

size of the button is 50, so this makes it as a perfect circle. However, when I profile this using instrument, it seems that it's dropping the FPS down a bit. Any other idea on how to do this performance wise?

like image 935
adit Avatar asked Apr 18 '26 09:04

adit


1 Answers

Rasterize it!

self.userProfileButton.layer.shouldRasterize = YES;
//For retina screens:
self.userProfileButton.layer.rasterizationScale = [[UIScreen mainScreen] scale];
like image 165
ninjaneer Avatar answered Apr 20 '26 02:04

ninjaneer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!