Layer conversion matrix (CATransform3D, etc.), But with IBDesignable?

This class will put the point of view on the vertical image.

It works fine, but does not work in the storyboard with IBDesignable. This is very sad.

Is it possible to use CATransform3D, etc. for live display on a storyboard with IBDesignable ??

// Twist.swift .. twist on Y, perspective from the left import UIKit @IBDesignable class Twist:UIViewController { @IBInspectable var perspective:CGFloat = 0.5 // -1 to 1 @IBOutlet var im:UIView! // the image you want to twist on y override func prepareForInterfaceBuilder() { twist(perspective) } override func viewDidAppear(animated: Bool) { twist(perspective) super.viewWillAppear(animated) } func twist(f:CGFloat) // -1 to 1 { // hinge around left edge im.layer.anchorPoint = CGPointMake(0, 0.5) im.center = CGPointMake(0.0, self.view.bounds.size.height/2.0) // base transform, twist on y var t:CATransform3D = CATransform3DIdentity t.m34 = -1/500 im.layer.transform = t im.layer.transform = CATransform3DRotate(t, f*CGFloat(M_PI_2), 0, 1, 0); } } 
+4
swift xcode7 calayer ibdesignable
May 18 '16 at 23:27
source share
1 answer

I already had a problem with live preview transformations. This seems to just not work, maybe not yet implemented.

There is a thing, only UIView can be @IBDesignable. Here you can see that both @UIDesignable classes cannot be displayed. For example, I created the TwistableView class.

Class inspector for custom view controller Class inspector for custom view

+1
May 19 '16 at 10:09
source share



All Articles