我想制作一个在视图中心打招呼的应用程序,等待几秒钟并动画到顶部(有点像您在许多应用程序中看到的登录视图)
无论我尝试什么,我都无法将文本保持在 x 轴的中心。你能看看我的代码并告诉我错误是什么吗?
谢谢
// Blur Effect
var blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Light)
var blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.bounds
view.addSubview(blurEffectView)
// Vibrancy Effect
var vibrancyEffect = UIVibrancyEffect(forBlurEffect: blurEffect)
var vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect)
vibrancyEffectView.frame = view.bounds
// Add label to the vibrancy view
vibrancyEffectView.contentView.addSubview(vibrantLabel)
vibrantLabel.textAlignment = NSTextAlignment.Center
// Add the vibrancy view to the blur view
blurEffectView.contentView.addSubview(vibrancyEffectView)
UIView.animateWithDuration(1, delay: 1, options: .CurveEaseIn, animations: {() -> Void in
self.vibrantLabel.frame = CGRectMake(0, 100, self.vibrantLabel.frame.width, self.vibrantLabel.frame.height)
}, completion: {(finished: Bool) -> Void in
self.view.alpha = 1
})