Open ghost opened 4 years ago
I believe this behavior is due to following code:
public override init(frame: CGRect) {
super.init(frame: frame)
setNeedsLayout()
layoutIfNeeded()
}
layout right after initialization cause all frames set, lazy variables initialize and calculate, even if there is no frame, and more importantly, positions calculated using initial value of lineWidth = 8
and hardcoded width and height frame.
public override init(frame: CGRect) {
super.init(frame: frame)
}
I believe this one will solve exact issue, and allows autolayout without frame using let circularProgress = KYCircularProgress()
.
But I dont know the initial purpose of these lines so cant say its solution
I have issue setting correct width and height for progress view.
For this code, and constrainting
circularProgressView
to5
for top, bottom, trailing and aspectRatio 1 (perfect square):I am getting following result
As you can see, autolayout setting correct frame according to white background color, inner circleViews are resized (from
100, 100
to41, 41
frame). But inner circles are not perfectly centered, approximately: (left: 5 top: 5, bottom: 8, right: 8), and dont have size I need (same as white circle). Am I missing something? circularProgressView.setNeedsLayout on parent LayoutSubviews doesnt work.Swift 5, XCode 11.3.1 (11C504)