Browse Source

make the cell respect the trailing margin

Jonas Reinsch 7 năm trước cách đây
mục cha
commit
21d4b33771
1 tập tin đã thay đổi với 9 bổ sung2 xóa
  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()