Yes there is. Here is what I did:
I created a file with a name Labels
that had a structure withCGFloats
import Foundation
import UIKit
struct Labels {
let labelXCord:CGFloat = 21
let labelYCord:CGFloat = 50
}
Then, in mine, ViewController
I made struct a constant, and then used the constant from the Labels structure in label coordinates.
import UIKit
class ViewController: UIViewController {
let labels = Labels()
override func viewDidLoad() {
super.viewDidLoad()
let label = UILabel(frame: CGRectMake(labels.labelXCord, 0, 200, 21))
label.center = CGPointMake(160, 284)
label.textAlignment = NSTextAlignment.Center
label.text = "I'am a test label"
self.view.addSubview(label)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Update:
Is that more than what you were thinking?
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var label0: UILabel!
@IBOutlet weak var label1: UILabel!
@IBOutlet weak var label2: UILabel!
@IBOutlet weak var label3: UILabel!
let labels = Labels()
override func viewDidLoad() {
super.viewDidLoad()
label0.frame = CGRectMake(labels.labelXCord, labels.labelYCord, 152, 152)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
And I think you can use this to change only the X coordinate:
label1.frame.origin.x = labels.labelXCord
for .