-
Notifications
You must be signed in to change notification settings - Fork 288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Intialization performance #21
Comments
Hi @Remyoman, - (void)setOnCheckColor:(UIColor *)onCheckColor {
_onCheckColor = onCheckColor;
if (self.layer.sublayers > 0) {
[self reload];
}
} This solution doesn't seem amazing either. Let me know if you can come up with something better! |
@Boris-Em Thank you for your fast response. I agree simple if checks like these feel unelegant and I understand the need for the reload call. The best place to make the change would be here in my opinion: - (void)reload {
[self.offBoxLayer removeFromSuperlayer];
self.offBoxLayer = nil;
[self.onBoxLayer removeFromSuperlayer];
self.onBoxLayer = nil;
[self.checkMarkLayer removeFromSuperlayer];
self.checkMarkLayer = nil;
if (self.window) {
[self setNeedsDisplay];
[self layoutIfNeeded];
}
} We only need to disable the intensive layout methods whilst the control isn't drawn yet. I will see if I can come up with something, I should have some time to look into some options today. Edit (also reflected in code): Using a self.window check seems to work for programatically initialised checkboxes as well. It's not great, but I haven't found other ways to have a fast and clean check for this situation. |
Hi @Remyoman, |
@Boris-Em I see, that's unfortunate. |
Fixed in #93 |
Currently I am using this library to add a number of checkboxes to a view controller as a visual feedback indicator towards the user. I have a view controller that contains 16 checboxes, which are set up in Storyboard with custom fill-, tint- and onCheck colors.
I noticed it took a long time to present this view controller and started profiling to look into the issue.
I then noticed that the custom attributes all make a reload call which is taking alot of time to process.
The reload call itself calls setNeedsDisplay and layoutIfNeeded, which will be done 3 times before awakeFromNib is even called in my case. What would be the most approriate solution for this problem? I assume a flag that gets set in awakeFromNib is a bit hacky, perhaps.
I can make some time tomorrow to submit a pull request with a simple fix.
The text was updated successfully, but these errors were encountered: