Skip to content

Instantly share code, notes, and snippets.

@tdtsh
Last active January 22, 2016 09:50
Show Gist options
  • Save tdtsh/617fd463c72da3edb26c to your computer and use it in GitHub Desktop.
Save tdtsh/617fd463c72da3edb26c to your computer and use it in GitHub Desktop.
UIViewをフェードイン
func renderView() {
/**
* ボタン
*/
let buttonTake = UIButton(frame: CGRect.init(x: 0, y: 0, width: self.view.frame.size.width - 50, height: 50))
buttonTake.backgroundColor = UIColor.init(colorLiteralRed: 0.3, green: 0.3, blue: 0.7, alpha: 0.5)
buttonTake.alpha = 0
buttonTake.layer.cornerRadius = 5.0
buttonTake.layer.masksToBounds = true
buttonTake.setTitle("ボタンです", forState: UIControlState.Normal)
buttonTake.layer.position = CGPoint(x: self.view.bounds.width/2, y:self.view.bounds.height - 55)
buttonTake.addTarget(self, action: "takePhoto:", forControlEvents: .TouchUpInside)
self.view.addSubview(buttonTake)
/**
* フェードイン
*/
UIView.animateWithDuration(0.8, delay: 1.0, options: UIViewAnimationOptions.CurveEaseInOut,
animations: {() -> Void in
buttonTake.alpha = 0.6
},
completion: {(finished: Bool) -> Void in
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment