Border Setting for TextView (Xcode 6.1)

I tried to find the answer to this question and every time I guess that I know too much. I am newbie. I just created a new, unfilled application. I dragged the TextView onto the storyboard. What should I do to give him a border?

There is currently no code other than the standard auto-generated code.

+6
source share
1 answer

Here are the steps: If you allow Xcode to create a project, go to the ViewController.swift file. Here you can create a way out.

@IBOutlet var text : UITextField? 

Now you can connect the text string to the text field in the storyboard. You can do this by choosing an editor’s assistant. Then the control drags the line from the outlet to the code in the text box.

After the text field is connected, you can add code to create the border in the viewDidLoad function.

 class ViewController: UIViewController { @IBOutlet var text : UITextField? override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. text!.layer.borderWidth = 1 text!.layer.borderColor = UIColor.redColor().CGColor } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } 
+23
source

Source: https://habr.com/ru/post/978158/


All Articles