Skip to content

Shadows don't always resize properly #25

@jdee

Description

@jdee

If you use NSLayoutConstraints properly, you can make the knob control resize continuously on rotation. But if you have shadows and use a shadow path (by setting the middleLayerShadowPath, foregroundLayerShadowPath and/or knobRadius properties), the shadow will not transform continuously with the control, which doesn't look very nice. You'll have to adjust it after the rotation is complete. If you don't use a shadow path, everything works fine, but the performance is not as good.

It is possible to animate the shadowPath property of a CALayer. Getting this right probably means something like:

override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
    super.willRotateToInterfaceOrientation(toInterfaceOrientation, duration: duration)
    let frame = computeNewFrameForKnobControl()
    knobControl.setFrame(frame, duration: duration)
}

With a new setFrame:duration: selector, you could properly animate the control with a rotation and in general animate the shadow path along with any change to the control frame.

A fix for this may wait until after the control moves to the Violation framework.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions