class ViewController: UIViewController, UIImagePickerControllerDelegate,
UINavigationControllerDelegate, UITextFieldDelegate {
@IBOutlet weak var topText: UITextField!
@IBOutlet weak var bottomText: UITextField!
@IBOutlet weak var imagePickerView: UIImageView!
//let stokeColor = NSStrokeColorAttributeName("stoke")
let memeTextAttributes:[String:Any] = [
NSAttributedStringKey.strokeColor.rawValue: UIColor.blue/* TODO: fill in appropriate UIColor */,
NSAttributedStringKey.foregroundColor.rawValue: UIColor.cyan/* TODO: fill in appropriate UIColor */,
NSAttributedStringKey.font.rawValue: UIFont(name: "HelveticaNeue-CondensedBlack", size: 40)!,
NSAttributedStringKey.strokeWidth.rawValue: 0.5/* TODO: fill in appropriate Float */]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
topText.textAlignment = .center
topText.text = "TOP"
topText.delegate = self
topText.borderStyle = .none
topText.defaultTextAttributes = memeTextAttributes
bottomText.textAlignment = .center
bottomText.text = "BOTTOM"
bottomText.delegate = self
topText.borderStyle = .none
bottomText.defaultTextAttributes = memeTextAttributes
}
最佳答案
看起来是因为您在 topText
上设置了两次边框样式...
topText.textAlignment = .center
topText.text = "TOP"
topText.delegate = self
// you set top text border style to none here...
topText.borderStyle = .none
topText.defaultTextAttributes = memeTextAttributes
bottomText.textAlignment = .center
bottomText.text = "BOTTOM"
bottomText.delegate = self
// then set it again here... pretty sure you want this to be bottomText.borderStyle = .none
topText.borderStyle = .none
bottomText.defaultTextAttributes = memeTextAttributes
关于ios - 为什么我的 BottomText 边框没有禁用,但 topText 可以正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51904918/