title: How to figure out what attribute I need to add and find out how to write them when I make a custom button & text field (also other UIs)
body: <p>I'm pretty new to Swift and want to ask a question about when we make a custom UI.</p>
  <p>The image below is something I made today based on a tutorial video of how to make a custom UI.
  <a href="https://i.stack.imgur.com/NQBQU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NQBQU.png" alt="enter image description here" /></a></p>
  <p>and these are the codes for making the button and text fields.</p>
  <pre><code>import UIKit
  
  class CustomTextField: UITextField {
      
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
          setupTextFeild()
      }
      
      
      private func setupTextFeild() {
          layer.cornerRadius = 30
          layer.shadowColor = UIColor.black.cgColor
          layer.shadowOffset = CGSize(width: 0.0, height: 6.0)
          layer.shadowRadius = 8
          layer.shadowOpacity = 0.5
          clipsToBounds = true
          layer.masksToBounds = false
          
          textColor = .black
          backgroundColor = UIColor(white: 1.0, alpha: 0.85)
          autocorrectionType = .no
          
          let placeholder = self.placeholder != nil ? self.placeholder! : &quot;&quot;
          
          attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSAttributedString.Key.foregroundColor : UIColor.darkGray])
          
          let indentView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 10))
          leftView = indentView
          leftViewMode = .always
          
      }
      
      
      
  }
  </code></pre>
  <p>here is another one</p>
  <pre><code>import UIKit
  
  class CustomButton: UIButton {
      
      // for storyboard
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
          setupButton()
      }
      
      
      func setupButton() {
          setShadow()
          setTitleColor(.white, for: .normal)
          layer.cornerRadius = 30
      }
      
      
      private func setShadow() {
          layer.shadowColor = UIColor.black.cgColor
          layer.shadowOffset = CGSize(width: 0.0, height: 6.0)
          layer.shadowRadius = 8
          layer.shadowOpacity = 0.5
          clipsToBounds = true
          layer.masksToBounds = false
      }
  }
  </code></pre>
  <p>It seems ok for now but the problem is I just follow the code on Youtube and I don't think I can write those codes all by myself. Also, in the video, a guy didn't describe how he figured out writing, for example, like the code below</p>
  <pre><code>layer.cornerRadius = 30
          layer.shadowColor = UIColor.black.cgColor
          layer.shadowOffset = CGSize(width: 0.0, height: 6.0)
          layer.shadowRadius = 8
          layer.shadowOpacity = 0.5
          clipsToBounds = true
          layer.masksToBounds = false
  </code></pre>
  <p>I want to know, for example, where the layer is coming from, why you know you need to write a layer first if you have to write code from scratch.</p>
  <p>I kind of understand I need to put <code>layer.cornerRadius = 30</code> if I want to add a corner radius to my buttons, but is there any document saying I need to write like <code>layer.cornerRadius</code> in order to add corner radius (or how can I figure out I need to write like <code>layer.cornerRadius</code>)? I have no idea what properties I can write in my setupTextFeild() &amp; setupButton() functions because I could not find any document describing attributes I can add when I make custom UIs. Is that something I should know when I write code in Swift or is there any document telling what properties I can add when making buttons, text fields e.t.c.</p>
  <p>I think my English is not clear enough to tell the points I want to ask, but I hope it makes sense.</p>