Skip to content

Instantly share code, notes, and snippets.

@a-eid a-eid/code.swift
Created Jan 17, 2018

Embed
What would you like to do?
import UIKit
class Second: UIViewController {
@IBOutlet weak var trigger: RoundButton!
@IBOutlet weak var right: RoundButton!
@IBOutlet weak var left: RoundButton!
@IBOutlet weak var top: RoundButton!
var clicked = false
var rightCenter: CGPoint!
var leftCenter: CGPoint!
var topCenter: CGPoint!
override func viewDidLoad() {
super.viewDidLoad()
topCenter = top.center
rightCenter = right.center
leftCenter = left.center
}
func buttonToInitPosition() {
top.center = trigger.center
left.center = trigger.center
right.center = trigger.center
}
func buttonToDestPosition() {
top.center = topCenter
left.center = leftCenter
right.center = rightCenter
top.alpha = 1
left.alpha = 1
right.alpha = 1
}
@IBAction func triggerClicked(_ sender: RoundButton) {
if clicked{
buttonToDestPosition()
clicked = false
}else{
buttonToInitPosition()
clicked = true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.