I am experiencing motion effect oscillations using the following code
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window!.rootViewController = ExampleController()
self.window!.makeKeyAndVisible()
return true
}
}
class ExampleController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let redView = UIView(frame: CGRect(x: 200, y: 200,
width: 800, height: 500))
redView.backgroundColor = UIColor.redColor().colorWithAlphaComponent(0.5)
self.view.addSubview(redView)
let effect = UIInterpolatingMotionEffect(keyPath: "center.x",
type: .TiltAlongHorizontalAxis)
effect.minimumRelativeValue = -100
effect.maximumRelativeValue = 100
let effectGroup = UIMotionEffectGroup()
effectGroup.motionEffects = [effect]
redView.motionEffects = [effectGroup]
}
}
resulting in the following behavior both in Simulator and on the new Apple TV
Is there a way to avoid the oscillations?