Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/122.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为什么我的底部文本边框没有被禁用,但topText正在工作?_Ios_Swift_Uitextfield - Fatal编程技术网

Ios 为什么我的底部文本边框没有被禁用,但topText正在工作?

Ios 为什么我的底部文本边框没有被禁用,但topText正在工作?,ios,swift,uitextfield,Ios,Swift,Uitextfield,看起来是因为您在topText上设置了两次边框样式 class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITextFieldDelegate { @IBOutlet weak var topText: UITextField! @IBOutlet weak var bottomText: UITextField! @IBOutl

看起来是因为您在
topText
上设置了两次边框样式

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.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