I have a UITextField object with the text property set to "hi". However these two lines have no affect on where "hi" is located
myUITextObject.contentVerticalAlignment = UIControlContentVerticalAlignment.Center
myUITextObject.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Center
Is this a bug in Swift? If so how do I go about logging this as a bug so Apple can fix it in the next Swift release?
Dave Wood
You would want to write it like this:
myUITextObject.textAlignment = .center
(Edited to change from .Center to .center)
What you're looking for is the textAlignment property; try this:
myUITextObject.textAlignment = NSTextAlignmentCenter;
来源:https://stackoverflow.com/questions/24588939/how-to-center-uitextfield-text-in-swift
