-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Separator lines in form and grouped-row-table widgets appear in the wrong places. This happens only in Simulator and only one the first page view. The separators draw properly on real iPhones and after refreshing or updating the page.
Here is the code that draws the separators:
applin-ios/Sources/ApplinIos/view/column_view.swift
Lines 96 to 125 in 7b19c18
| override func draw(_ rect: CGRect) { | |
| // TODO: Fix bug on Simulator which causes lines to be in the wrong place on first load. See Checkboxes demo page. | |
| if let color = self.separatorColor, let ctx = UIGraphicsGetCurrentContext() { | |
| // Draw a line left-to-right between subviews | |
| let left = 0.0 | |
| let right = self.bounds.size.width | |
| ctx.setLineCap(.round) | |
| ctx.setLineWidth(CGFloat(SEPARATOR_THICKNESS)) | |
| ctx.setStrokeColor(color.cgColor) | |
| ctx.beginPath() | |
| if let first = self.orderedSubviews.first, let sepThickness = self.separatorThickness() { | |
| let y = first.frame.minY - CGFloat(sepThickness / 2.0) | |
| ctx.move(to: CGPoint(x: left, y: y)) | |
| ctx.addLine(to: CGPoint(x: right, y: y)) | |
| } | |
| for (n, a) in self.orderedSubviews.dropLast(1).enumerated() { | |
| let b = self.orderedSubviews[n + 1] | |
| let y = (a.frame.maxY + b.frame.minY) / 2.0 | |
| //Self.logger.trace("draw (\(left), \(y)) -> (\(right), \(y))") | |
| ctx.move(to: CGPoint(x: left, y: y)) | |
| ctx.addLine(to: CGPoint(x: right, y: y)) | |
| } | |
| if let last = self.orderedSubviews.last, let sepThickness = self.separatorThickness() { | |
| let y = last.frame.maxY + CGFloat(sepThickness / 2.0) | |
| ctx.move(to: CGPoint(x: left, y: y)) | |
| ctx.addLine(to: CGPoint(x: right, y: y)) | |
| } | |
| ctx.strokePath() | |
| } | |
| } |
It seems that UIKit calls draw before laying out the views. Or it fails to update each view's frame field. I have spent many hours trying to find a workaround. If anyone has ideas, please post them here.
Metadata
Metadata
Assignees
Labels
No labels
