Преглед изворни кода

make the cell respect the trailing margin

Jonas Reinsch пре 7 година
родитељ
комит
21d4b33771
1 измењених фајлова са 9 додато и 2 уклоњено
  1. 9 2
      deltachat-ios/CredentialsController.swift

+ 9 - 2
deltachat-ios/CredentialsController.swift

@@ -16,9 +16,15 @@ class TextFieldCell:UITableViewCell {
         
         textLabel?.text = "\(description):"
         contentView.addSubview(textField)
-        
+
         textField.translatesAutoresizingMaskIntoConstraints = false
-        textField.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -15).isActive = true
+        
+        // see: https://stackoverflow.com/a/35903650
+        // this makes the textField respect the trailing margin of
+        // the table view cell
+        let margins = contentView.layoutMarginsGuide
+        let trailing = margins.trailingAnchor
+        textField.trailingAnchor.constraint(equalTo: trailing).isActive = true
         textField.centerYAnchor.constraint(equalTo: contentView.centerYAnchor).isActive = true
         textField.textAlignment = .right
 
@@ -27,6 +33,7 @@ class TextFieldCell:UITableViewCell {
         selectionStyle = .none
     }
     
+    
     override func setSelected(_ selected: Bool, animated: Bool) {
         if selected {
             textField.becomeFirstResponder()