@@ -9,6 +9,11 @@ class EditableTextCell: UITableViewCell {
99 set ( value) { valueTextField. text = value }
1010 }
1111
12+ var placeholder : String ? {
13+ get { return valueTextField. placeholder }
14+ set ( value) { valueTextField. placeholder = value }
15+ }
16+
1217 let valueTextField : UITextField = {
1318 let valueTextField = UITextField ( )
1419 valueTextField. textAlignment = . left
@@ -29,12 +34,13 @@ class EditableTextCell: UITableViewCell {
2934 valueTextField. delegate = self
3035 contentView. addSubview ( valueTextField)
3136 valueTextField. translatesAutoresizingMaskIntoConstraints = false
32- let bottomAnchorConstraint = contentView. layoutMarginsGuide. bottomAnchor. constraint ( equalToSystemSpacingBelow: valueTextField. bottomAnchor, multiplier: 1 )
37+ // Reduce the bottom margin by 0.5pt to maintain the default cell height (44pt)
38+ let bottomAnchorConstraint = contentView. layoutMarginsGuide. bottomAnchor. constraint ( equalTo: valueTextField. bottomAnchor, constant: - 0.5 )
3339 bottomAnchorConstraint. priority = . defaultLow
3440 NSLayoutConstraint . activate ( [
35- valueTextField. leadingAnchor. constraint ( equalToSystemSpacingAfter : contentView. layoutMarginsGuide. leadingAnchor, multiplier : 1 ) ,
36- contentView. layoutMarginsGuide. trailingAnchor. constraint ( equalToSystemSpacingAfter : valueTextField. trailingAnchor, multiplier : 1 ) ,
37- valueTextField . topAnchor. constraint ( equalToSystemSpacingBelow : contentView . layoutMarginsGuide . topAnchor, multiplier : 1 ) ,
41+ valueTextField. leadingAnchor. constraint ( equalTo : contentView. layoutMarginsGuide. leadingAnchor) ,
42+ contentView. layoutMarginsGuide. trailingAnchor. constraint ( equalTo : valueTextField. trailingAnchor) ,
43+ contentView . layoutMarginsGuide . topAnchor. constraint ( equalTo : valueTextField . topAnchor) ,
3844 bottomAnchorConstraint
3945 ] )
4046 }
@@ -50,6 +56,7 @@ class EditableTextCell: UITableViewCell {
5056 override func prepareForReuse( ) {
5157 super. prepareForReuse ( )
5258 message = " "
59+ placeholder = nil
5360 }
5461}
5562
0 commit comments