Swift 4 - Snapshotting error with custom UIView












0















In my project, I made a subclass of a UIView, which is basically a container for a UITextField. Everything works fine except that I get a strange error message in my console when I am selecting the textfield on screen, and I don't know how to do to make it disapear :




[Snapshotting] Snapshotting a view (0x119d2d240, _UIReplicantView)
that has not been rendered at least once requires
afterScreenUpdates:YES.




I tried to place some view.layoutIfNeeded() at some points but the message remains. Here is my code :



import UIKit

class BTShimmerTextField: BTShimmerView {

let nestedTextField = UITextField()

var didPressReturn: (() -> ())? = nil

var placeholder: String? {
get {
return nestedTextField.placeholder
}
set {
nestedTextField.placeholder = newValue
}
}

var darkColor: UIColor? {
get {
return darkView.backgroundColor
}
set {
darkView.backgroundColor = newValue
}
}

var lightColor: UIColor? {
get {
return lightView.backgroundColor
}
set {
lightView.backgroundColor = newValue
}
}

var isSecureTextEntry: Bool {
get {
return nestedTextField.isSecureTextEntry
}
set {
nestedTextField.isSecureTextEntry = newValue
}
}

var autocorrectionType: UITextAutocorrectionType {
get {
return nestedTextField.autocorrectionType
}
set {
nestedTextField.autocorrectionType = newValue
}
}

override init(){
super.init()
setupTextField()
}

override init(frame: CGRect) {
super.init(frame: frame)
setupTextField()
}

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupTextField()
}

fileprivate func setupTextField(){

nestedTextField.backgroundColor = UIColor.white // UIColor(named: "BTDark")
nestedTextField.textAlignment = .center
nestedTextField.tintColor = UIColor(named: "BTDark")
nestedTextField.font = UIFont(name: "Metropolis-Regular", size: 16)
nestedTextField.keyboardAppearance = .dark
nestedTextField.delegate = self

self.addSubview(nestedTextField)

nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))

}

@discardableResult
override func becomeFirstResponder() -> Bool {
return nestedTextField.becomeFirstResponder()
}

}

extension BTShimmerTextField: UITextFieldDelegate {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if textField == nestedTextField {
nestedTextField.resignFirstResponder()
if let didPressReturn = didPressReturn { didPressReturn() }
return false
}
return true
}
}


Note: The BTShimmerView is also a subclass of a UIView, in which I set 2 UIView with 2 different backgrounds, with a CAGradientLayer to make some kind of reflection effect.



Here is how I add it to my view :



import UIKit

class LoginViewController: UIViewController {

override var prefersStatusBarHidden: Bool {
return true
}


var loginView = BTShimmerTextField()
var passwordView = BTShimmerTextField()

override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = UIColor(named: "BTDark")
setupLoginViews()

}


fileprivate func setupLoginViews(){

loginView.darkColor = UIColor(named: "BTDarkGold")
loginView.lightColor = UIColor(named: "BTGold")
loginView.placeholder = "Identifiant"
loginView.didPressReturn = { self.passwordView.becomeFirstResponder() }
loginView.autocorrectionType = .no
view.addSubview(loginView)

loginView.translatesAutoresizingMaskIntoConstraints = false
loginView.heightAnchor.constraint(equalToConstant: 30).isActive = true
loginView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.7).isActive = true
loginView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
loginView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -25).isActive = true


passwordView.darkColor = UIColor(named: "BTDarkGold")
passwordView.lightColor = UIColor(named: "BTGold")
passwordView.placeholder = "Mot de passe"
passwordView.isSecureTextEntry = true
passwordView.autocorrectionType = .no
view.addSubview(passwordView)

passwordView.translatesAutoresizingMaskIntoConstraints = false
passwordView.heightAnchor.constraint(equalToConstant: 30).isActive = true
passwordView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.7).isActive = true
passwordView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
passwordView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 25).isActive = true


}

}


Does anyone know how I can resolve this error? Is this error really problematic?










share|improve this question





























    0















    In my project, I made a subclass of a UIView, which is basically a container for a UITextField. Everything works fine except that I get a strange error message in my console when I am selecting the textfield on screen, and I don't know how to do to make it disapear :




    [Snapshotting] Snapshotting a view (0x119d2d240, _UIReplicantView)
    that has not been rendered at least once requires
    afterScreenUpdates:YES.




    I tried to place some view.layoutIfNeeded() at some points but the message remains. Here is my code :



    import UIKit

    class BTShimmerTextField: BTShimmerView {

    let nestedTextField = UITextField()

    var didPressReturn: (() -> ())? = nil

    var placeholder: String? {
    get {
    return nestedTextField.placeholder
    }
    set {
    nestedTextField.placeholder = newValue
    }
    }

    var darkColor: UIColor? {
    get {
    return darkView.backgroundColor
    }
    set {
    darkView.backgroundColor = newValue
    }
    }

    var lightColor: UIColor? {
    get {
    return lightView.backgroundColor
    }
    set {
    lightView.backgroundColor = newValue
    }
    }

    var isSecureTextEntry: Bool {
    get {
    return nestedTextField.isSecureTextEntry
    }
    set {
    nestedTextField.isSecureTextEntry = newValue
    }
    }

    var autocorrectionType: UITextAutocorrectionType {
    get {
    return nestedTextField.autocorrectionType
    }
    set {
    nestedTextField.autocorrectionType = newValue
    }
    }

    override init(){
    super.init()
    setupTextField()
    }

    override init(frame: CGRect) {
    super.init(frame: frame)
    setupTextField()
    }

    required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    setupTextField()
    }

    fileprivate func setupTextField(){

    nestedTextField.backgroundColor = UIColor.white // UIColor(named: "BTDark")
    nestedTextField.textAlignment = .center
    nestedTextField.tintColor = UIColor(named: "BTDark")
    nestedTextField.font = UIFont(name: "Metropolis-Regular", size: 16)
    nestedTextField.keyboardAppearance = .dark
    nestedTextField.delegate = self

    self.addSubview(nestedTextField)

    nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))

    }

    @discardableResult
    override func becomeFirstResponder() -> Bool {
    return nestedTextField.becomeFirstResponder()
    }

    }

    extension BTShimmerTextField: UITextFieldDelegate {
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
    if textField == nestedTextField {
    nestedTextField.resignFirstResponder()
    if let didPressReturn = didPressReturn { didPressReturn() }
    return false
    }
    return true
    }
    }


    Note: The BTShimmerView is also a subclass of a UIView, in which I set 2 UIView with 2 different backgrounds, with a CAGradientLayer to make some kind of reflection effect.



    Here is how I add it to my view :



    import UIKit

    class LoginViewController: UIViewController {

    override var prefersStatusBarHidden: Bool {
    return true
    }


    var loginView = BTShimmerTextField()
    var passwordView = BTShimmerTextField()

    override func viewDidLoad() {
    super.viewDidLoad()
    view.backgroundColor = UIColor(named: "BTDark")
    setupLoginViews()

    }


    fileprivate func setupLoginViews(){

    loginView.darkColor = UIColor(named: "BTDarkGold")
    loginView.lightColor = UIColor(named: "BTGold")
    loginView.placeholder = "Identifiant"
    loginView.didPressReturn = { self.passwordView.becomeFirstResponder() }
    loginView.autocorrectionType = .no
    view.addSubview(loginView)

    loginView.translatesAutoresizingMaskIntoConstraints = false
    loginView.heightAnchor.constraint(equalToConstant: 30).isActive = true
    loginView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.7).isActive = true
    loginView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    loginView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -25).isActive = true


    passwordView.darkColor = UIColor(named: "BTDarkGold")
    passwordView.lightColor = UIColor(named: "BTGold")
    passwordView.placeholder = "Mot de passe"
    passwordView.isSecureTextEntry = true
    passwordView.autocorrectionType = .no
    view.addSubview(passwordView)

    passwordView.translatesAutoresizingMaskIntoConstraints = false
    passwordView.heightAnchor.constraint(equalToConstant: 30).isActive = true
    passwordView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.7).isActive = true
    passwordView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
    passwordView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 25).isActive = true


    }

    }


    Does anyone know how I can resolve this error? Is this error really problematic?










    share|improve this question



























      0












      0








      0








      In my project, I made a subclass of a UIView, which is basically a container for a UITextField. Everything works fine except that I get a strange error message in my console when I am selecting the textfield on screen, and I don't know how to do to make it disapear :




      [Snapshotting] Snapshotting a view (0x119d2d240, _UIReplicantView)
      that has not been rendered at least once requires
      afterScreenUpdates:YES.




      I tried to place some view.layoutIfNeeded() at some points but the message remains. Here is my code :



      import UIKit

      class BTShimmerTextField: BTShimmerView {

      let nestedTextField = UITextField()

      var didPressReturn: (() -> ())? = nil

      var placeholder: String? {
      get {
      return nestedTextField.placeholder
      }
      set {
      nestedTextField.placeholder = newValue
      }
      }

      var darkColor: UIColor? {
      get {
      return darkView.backgroundColor
      }
      set {
      darkView.backgroundColor = newValue
      }
      }

      var lightColor: UIColor? {
      get {
      return lightView.backgroundColor
      }
      set {
      lightView.backgroundColor = newValue
      }
      }

      var isSecureTextEntry: Bool {
      get {
      return nestedTextField.isSecureTextEntry
      }
      set {
      nestedTextField.isSecureTextEntry = newValue
      }
      }

      var autocorrectionType: UITextAutocorrectionType {
      get {
      return nestedTextField.autocorrectionType
      }
      set {
      nestedTextField.autocorrectionType = newValue
      }
      }

      override init(){
      super.init()
      setupTextField()
      }

      override init(frame: CGRect) {
      super.init(frame: frame)
      setupTextField()
      }

      required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      setupTextField()
      }

      fileprivate func setupTextField(){

      nestedTextField.backgroundColor = UIColor.white // UIColor(named: "BTDark")
      nestedTextField.textAlignment = .center
      nestedTextField.tintColor = UIColor(named: "BTDark")
      nestedTextField.font = UIFont(name: "Metropolis-Regular", size: 16)
      nestedTextField.keyboardAppearance = .dark
      nestedTextField.delegate = self

      self.addSubview(nestedTextField)

      nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))

      }

      @discardableResult
      override func becomeFirstResponder() -> Bool {
      return nestedTextField.becomeFirstResponder()
      }

      }

      extension BTShimmerTextField: UITextFieldDelegate {
      func textFieldShouldReturn(_ textField: UITextField) -> Bool {
      if textField == nestedTextField {
      nestedTextField.resignFirstResponder()
      if let didPressReturn = didPressReturn { didPressReturn() }
      return false
      }
      return true
      }
      }


      Note: The BTShimmerView is also a subclass of a UIView, in which I set 2 UIView with 2 different backgrounds, with a CAGradientLayer to make some kind of reflection effect.



      Here is how I add it to my view :



      import UIKit

      class LoginViewController: UIViewController {

      override var prefersStatusBarHidden: Bool {
      return true
      }


      var loginView = BTShimmerTextField()
      var passwordView = BTShimmerTextField()

      override func viewDidLoad() {
      super.viewDidLoad()
      view.backgroundColor = UIColor(named: "BTDark")
      setupLoginViews()

      }


      fileprivate func setupLoginViews(){

      loginView.darkColor = UIColor(named: "BTDarkGold")
      loginView.lightColor = UIColor(named: "BTGold")
      loginView.placeholder = "Identifiant"
      loginView.didPressReturn = { self.passwordView.becomeFirstResponder() }
      loginView.autocorrectionType = .no
      view.addSubview(loginView)

      loginView.translatesAutoresizingMaskIntoConstraints = false
      loginView.heightAnchor.constraint(equalToConstant: 30).isActive = true
      loginView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.7).isActive = true
      loginView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
      loginView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -25).isActive = true


      passwordView.darkColor = UIColor(named: "BTDarkGold")
      passwordView.lightColor = UIColor(named: "BTGold")
      passwordView.placeholder = "Mot de passe"
      passwordView.isSecureTextEntry = true
      passwordView.autocorrectionType = .no
      view.addSubview(passwordView)

      passwordView.translatesAutoresizingMaskIntoConstraints = false
      passwordView.heightAnchor.constraint(equalToConstant: 30).isActive = true
      passwordView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.7).isActive = true
      passwordView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
      passwordView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 25).isActive = true


      }

      }


      Does anyone know how I can resolve this error? Is this error really problematic?










      share|improve this question
















      In my project, I made a subclass of a UIView, which is basically a container for a UITextField. Everything works fine except that I get a strange error message in my console when I am selecting the textfield on screen, and I don't know how to do to make it disapear :




      [Snapshotting] Snapshotting a view (0x119d2d240, _UIReplicantView)
      that has not been rendered at least once requires
      afterScreenUpdates:YES.




      I tried to place some view.layoutIfNeeded() at some points but the message remains. Here is my code :



      import UIKit

      class BTShimmerTextField: BTShimmerView {

      let nestedTextField = UITextField()

      var didPressReturn: (() -> ())? = nil

      var placeholder: String? {
      get {
      return nestedTextField.placeholder
      }
      set {
      nestedTextField.placeholder = newValue
      }
      }

      var darkColor: UIColor? {
      get {
      return darkView.backgroundColor
      }
      set {
      darkView.backgroundColor = newValue
      }
      }

      var lightColor: UIColor? {
      get {
      return lightView.backgroundColor
      }
      set {
      lightView.backgroundColor = newValue
      }
      }

      var isSecureTextEntry: Bool {
      get {
      return nestedTextField.isSecureTextEntry
      }
      set {
      nestedTextField.isSecureTextEntry = newValue
      }
      }

      var autocorrectionType: UITextAutocorrectionType {
      get {
      return nestedTextField.autocorrectionType
      }
      set {
      nestedTextField.autocorrectionType = newValue
      }
      }

      override init(){
      super.init()
      setupTextField()
      }

      override init(frame: CGRect) {
      super.init(frame: frame)
      setupTextField()
      }

      required init?(coder aDecoder: NSCoder) {
      super.init(coder: aDecoder)
      setupTextField()
      }

      fileprivate func setupTextField(){

      nestedTextField.backgroundColor = UIColor.white // UIColor(named: "BTDark")
      nestedTextField.textAlignment = .center
      nestedTextField.tintColor = UIColor(named: "BTDark")
      nestedTextField.font = UIFont(name: "Metropolis-Regular", size: 16)
      nestedTextField.keyboardAppearance = .dark
      nestedTextField.delegate = self

      self.addSubview(nestedTextField)

      nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))

      }

      @discardableResult
      override func becomeFirstResponder() -> Bool {
      return nestedTextField.becomeFirstResponder()
      }

      }

      extension BTShimmerTextField: UITextFieldDelegate {
      func textFieldShouldReturn(_ textField: UITextField) -> Bool {
      if textField == nestedTextField {
      nestedTextField.resignFirstResponder()
      if let didPressReturn = didPressReturn { didPressReturn() }
      return false
      }
      return true
      }
      }


      Note: The BTShimmerView is also a subclass of a UIView, in which I set 2 UIView with 2 different backgrounds, with a CAGradientLayer to make some kind of reflection effect.



      Here is how I add it to my view :



      import UIKit

      class LoginViewController: UIViewController {

      override var prefersStatusBarHidden: Bool {
      return true
      }


      var loginView = BTShimmerTextField()
      var passwordView = BTShimmerTextField()

      override func viewDidLoad() {
      super.viewDidLoad()
      view.backgroundColor = UIColor(named: "BTDark")
      setupLoginViews()

      }


      fileprivate func setupLoginViews(){

      loginView.darkColor = UIColor(named: "BTDarkGold")
      loginView.lightColor = UIColor(named: "BTGold")
      loginView.placeholder = "Identifiant"
      loginView.didPressReturn = { self.passwordView.becomeFirstResponder() }
      loginView.autocorrectionType = .no
      view.addSubview(loginView)

      loginView.translatesAutoresizingMaskIntoConstraints = false
      loginView.heightAnchor.constraint(equalToConstant: 30).isActive = true
      loginView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.7).isActive = true
      loginView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
      loginView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: -25).isActive = true


      passwordView.darkColor = UIColor(named: "BTDarkGold")
      passwordView.lightColor = UIColor(named: "BTGold")
      passwordView.placeholder = "Mot de passe"
      passwordView.isSecureTextEntry = true
      passwordView.autocorrectionType = .no
      view.addSubview(passwordView)

      passwordView.translatesAutoresizingMaskIntoConstraints = false
      passwordView.heightAnchor.constraint(equalToConstant: 30).isActive = true
      passwordView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.7).isActive = true
      passwordView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
      passwordView.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 25).isActive = true


      }

      }


      Does anyone know how I can resolve this error? Is this error really problematic?







      swift uiview swift4 subclass






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 13:58









      Damon

      523318




      523318










      asked Nov 19 '18 at 13:54









      OlympiloutreOlympiloutre

      197114




      197114
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Found the solution. I had to set my constraints by overriding updateConstraints method, considering it's a subclass, like so :



          [...]
          // Constraints
          override func updateConstraints() {
          if(shouldSetupConstraints) {
          setupTextFieldConstraints()
          }
          super.updateConstraints()
          }

          fileprivate func setupTextFieldConstraints(){
          nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))
          }
          [...]





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376152%2fswift-4-snapshotting-error-with-custom-uiview%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Found the solution. I had to set my constraints by overriding updateConstraints method, considering it's a subclass, like so :



            [...]
            // Constraints
            override func updateConstraints() {
            if(shouldSetupConstraints) {
            setupTextFieldConstraints()
            }
            super.updateConstraints()
            }

            fileprivate func setupTextFieldConstraints(){
            nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))
            }
            [...]





            share|improve this answer




























              0














              Found the solution. I had to set my constraints by overriding updateConstraints method, considering it's a subclass, like so :



              [...]
              // Constraints
              override func updateConstraints() {
              if(shouldSetupConstraints) {
              setupTextFieldConstraints()
              }
              super.updateConstraints()
              }

              fileprivate func setupTextFieldConstraints(){
              nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))
              }
              [...]





              share|improve this answer


























                0












                0








                0







                Found the solution. I had to set my constraints by overriding updateConstraints method, considering it's a subclass, like so :



                [...]
                // Constraints
                override func updateConstraints() {
                if(shouldSetupConstraints) {
                setupTextFieldConstraints()
                }
                super.updateConstraints()
                }

                fileprivate func setupTextFieldConstraints(){
                nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))
                }
                [...]





                share|improve this answer













                Found the solution. I had to set my constraints by overriding updateConstraints method, considering it's a subclass, like so :



                [...]
                // Constraints
                override func updateConstraints() {
                if(shouldSetupConstraints) {
                setupTextFieldConstraints()
                }
                super.updateConstraints()
                }

                fileprivate func setupTextFieldConstraints(){
                nestedTextField.anchor(top: self.topAnchor, leading: self.leadingAnchor, trailing: self.trailingAnchor, bottom: self.bottomAnchor, padding: UIEdgeInsets(top: 2, left: 2, bottom: 2, right: 2))
                }
                [...]






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 '18 at 14:23









                OlympiloutreOlympiloutre

                197114




                197114






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376152%2fswift-4-snapshotting-error-with-custom-uiview%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to change which sound is reproduced for terminal bell?

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?