1

I've got a bezier with a stroke which is contained within a frame. My bezier resizes dynamically along with the frame very nicely, but the stroke width is static which makes it look bad at small sizes. (Notice how the stroke isn't proportional on the small star below.)

enter image description here

My first thought was to make the stroke width (normally 5) an expression that was based something like 5.0*(frame.width/standardwidth) but I'm not allowed to reference the frame variable.

How can I make an expression to calculate a stroke width based on the frame width? Or somehow make the stroke width dynamically sized like the rest of the elements within the frame?

Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229

1 Answers1

1

For me this works out of the box. That is:

"...somehow make the stroke width dynamically sized like the rest of the elements within the frame"

Versions:

  • PaintCode 3.4 (34000)
  • Xcode 9.4.1 (9F2000)
  • Swift 4.1.2

PaintCode Setup

PaintCode Setup

Custom View

import Foundation
import UIKit

@IBDesignable class StarView: UIView {

    override func draw(_ rect: CGRect) {
        StyleKit.drawStarIcon(frame: rect)
    }
}

Final Result

Final Result

GitHub

https://github.com/backslash-f/paintcode-tests

backslash-f
  • 7,923
  • 7
  • 52
  • 80
  • It doesn't look like you have your star inside a frame. When I put a frame around the star, then I don't get that Resizing option that you have (it's greyed out). – Kenny Wyland Sep 03 '18 at 22:34
  • ... and the stroke on my star stays at a static size which means it is thicker than it should be proportionally. – Kenny Wyland Sep 03 '18 at 22:41
  • Oh, that’s true. I don’t use Frames for simple resizing operations anymore. I remember they were absolutely necessary in previous PaintCode versions, but can now be dismissed in most cases. Do you really need that Frame? – backslash-f Sep 03 '18 at 22:42
  • 1
    Yeah, I just came back to essentially post what you just did. What I'm trying to do required a frame in PaintCode 1 and 2, but this new PaintCode 3 automatic resizing thing seems to inherently do what I want without having to mess with frames. Thanks! – Kenny Wyland Sep 03 '18 at 22:48