label is not growing when the text is longer - ios

I want a view that is centered in the superview but that grows due the content in this case a label. But I don't want it to grow that it doesn't fit in the screen anymore so thats why I pin the left and right.
I've put on a test viewcontroller:
import UIKit
import PureLayout
final class ViewController: UIViewController {
let container: UIView = {
let container = UIView(forAutoLayout: ())
container.backgroundColor = UIColor.blackColor()
container.clipsToBounds = true
return container
}()
let label: UILabel = {
let label = UILabel(forAutoLayout: ())
label.textAlignment = NSTextAlignment.Center
label.numberOfLines = 1
label.textColor = UIColor.redColor()
label.text = "This is a very very very long message"
return label
}()
var rightView: UIView = {
let view = UIView(forAutoLayout: ())
view.backgroundColor = .redColor()
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
self.container.addSubview(self.label)
self.view.addSubview(self.container)
self.view.addSubview(self.rightView)
self.container.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 20)
self.container.autoAlignAxisToSuperviewAxis(.Vertical)
self.container.autoSetDimension(.Height, toSize: 36)
self.container.layer.cornerRadius = 18
self.container.autoPinEdge(.Right, toEdge: .Left, ofView: self.rightView, withOffset: -20, relation: .LessThanOrEqual)
self.container.autoPinEdgeToSuperviewEdge(.Left, withInset: 20, relation: .GreaterThanOrEqual)
self.container.setContentCompressionResistancePriority(UILayoutPriorityRequired, forAxis: .Horizontal)
self.label.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsMake(10, 20, 10, 20))
self.rightView.autoPinEdgeToSuperviewEdge(.Right, withInset: 5)
self.rightView.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 20)
self.rightView.autoSetDimension(.Width, toSize: 50)
self.rightView.autoSetDimension(.Height, toSize: 60)
}
}
The result of this is:
Why is the black view not growing until it can't due the left and right constraint? The number of lines is 1 and the ContentCompressionResistancePriority is on?

You can change the font size to fit the width of the UILabel (non-multiline):
label.numberOfLines = 1;
label.adjustsFontSizeToFitWidth = true;
label.sizeToFit();
You need dynamic changes in height means then you can do like following
Dynamic UILabel changes
label.preferredMaxLayoutWidth = 500;
you can use the above code for set preferred max width, All the best :)

What are the leading and trailing constraints on the label, you could set the leading constraint to an inequality like greater than or equal something like 5. If you're happy for the font to get smaller, you could set adjustsFontSizeToFitWidth to YES.

Try this
testLabel.text = "long text......."
testLabel.numberOfLines = 0
testLabel.sizeToFit()

Set the label.numberOfLines = 0 in your code then only it will expand based the text that you have.

Im using xcode 4. I have tested this issue
Xcode screenshot
After running in iPhone 6
Since you have a view besides the label,It wont come delete or move the view to another layer so that the label resizes automatically with code
[labelName sizeToFit];

Related

UIStackView distribution and alignment of a multiline UILabel

I' struggling with some basic UIStackView distribution and alignment stuff.
I have an UICollectionViewCell which has a horizontal UIStackView at the contentView subview. This UIStackView has a vertical UIStackView for the three labels itself, and of course the UIImageView.
This is the code snippet for the screenshot below:
func createSubViews() {
// contains the UIStackview with the 3 labels and the UIImageView
containerStackView = UIStackView()
containerStackView.axis = .horizontal
containerStackView.distribution = .fill
containerStackView.alignment = .top
contentView.addSubview(containerStackView)
// the UIStackView for the labels
verticalStackView = UIStackView()
verticalStackView.axis = .vertical
verticalStackView.distribution = .fill
verticalStackView.spacing = 10.0
containerStackView.addArrangedSubview(verticalStackView)
categoryLabel = UILabel()
categoryLabel.font = UIFont.preferredFont(forTextStyle: .caption1)
categoryLabel.textColor = UIColor.lightGray
verticalStackView.addArrangedSubview(categoryLabel)
titleLabel = UILabel()
titleLabel.numberOfLines = 3
titleLabel.lineBreakMode = .byWordWrapping
verticalStackView.addArrangedSubview(titleLabel)
timeLabel = UILabel()
timeLabel.font = UIFont.preferredFont(forTextStyle: .caption1)
timeLabel.textColor = UIColor.lightGray
verticalStackView.addArrangedSubview(timeLabel)
// UIImageView
imageView = UIImageView()
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.layer.cornerRadius = 5
layer.masksToBounds = true
containerStackView.addArrangedSubview(imageView)
}
What I want to achive is, that the "time label" ("3 days ago") is always placed at the bottom of each UICollectionViewCell (aligned with the bottom of the UIImageView), regardless of the different title label lines.
I've played with various UIStackView distributions, constraining the "time label" and with the hugging priority of the "title label".
But anyhow I can't get it right. Any hints?
UPDATE
Since you're setting titleLabel.numberOfLines = 3, one way to do this is simply to append three newlines to the title text. That will force titleLabel to always consume its full height of three lines, forcing timeLabel to the bottom.
That is, when you set titleLabel.text, do it like this:
titleLabel.text = theTitle + "\n\n\n"
ORIGINAL
If you let one of the labels stretch vertically, the stretched label's text will be centered vertically within the stretched label's bounds, which is not what you want. So we can't let the labels stretch vertically. Therefore we need to introduce a padding view that can stretch but is otherwise invisible.
If the padding view gets squeezed down to zero height, the stack view will still put spacing before and after it, leading to double-spacing between titleLabel and timeLabel, which you also don't want.
So we'll need to implement all the spacing using padding views. Change verticalStackView.spacing to 0.
Add a generic UIView named padding1 to verticalStackView after categoryLabel, before titleLabel. Constrain its height to equal 10.
Add a generic UIView named padding2 to verticalStackView after titleLabel, before timeLabel. Constrain its height to greater than or equal to 10 so that it can stretch.
Set the vertical hugging priorities of categoryLabel, titleLabel, and timeLabel to required, so that they will not stretch vertically.
Constrain the height of verticalStackView to the height of containerStackView so that it will stretch one or more of its arranged subviews if needed to fill the vertical space available. The only arranged subview that can stretch is padding2, so it will stretch, keeping the title text near the top and the time text at the bottom.
Also, constrain your containerStackView to the bounds of contentView and set containerStackView.translatesAutoresizingMaskIntoConstraints = false.
Result:
Here's my playground:
import UIKit
import PlaygroundSupport
class MyCell: UICollectionViewCell {
var containerStackView: UIStackView!
var verticalStackView: UIStackView!
var categoryLabel: UILabel!
var titleLabel: UILabel!
var timeLabel: UILabel!
var imageView: UIImageView!
func createSubViews() {
// contains the UIStackview with the 3 labels and the UIImageView
containerStackView = UIStackView()
containerStackView.axis = .horizontal
containerStackView.distribution = .fill
containerStackView.alignment = .top
contentView.addSubview(containerStackView)
// the UIStackView for the labels
verticalStackView = UIStackView()
verticalStackView.axis = .vertical
verticalStackView.distribution = .fill
verticalStackView.spacing = 0
containerStackView.addArrangedSubview(verticalStackView)
categoryLabel = UILabel()
categoryLabel.font = UIFont.preferredFont(forTextStyle: .caption1)
categoryLabel.textColor = UIColor.lightGray
verticalStackView.addArrangedSubview(categoryLabel)
let padding1 = UIView()
verticalStackView.addArrangedSubview(padding1)
titleLabel = UILabel()
titleLabel.numberOfLines = 3
titleLabel.lineBreakMode = .byWordWrapping
verticalStackView.addArrangedSubview(titleLabel)
let padding2 = UIView()
verticalStackView.addArrangedSubview(padding2)
timeLabel = UILabel()
timeLabel.font = UIFont.preferredFont(forTextStyle: .caption1)
timeLabel.textColor = UIColor.lightGray
verticalStackView.addArrangedSubview(timeLabel)
// UIImageView
imageView = UIImageView()
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
imageView.layer.cornerRadius = 5
layer.masksToBounds = true
containerStackView.addArrangedSubview(imageView)
categoryLabel.setContentHuggingPriority(.required, for: .vertical)
titleLabel.setContentHuggingPriority(.required, for: .vertical)
timeLabel.setContentHuggingPriority(.required, for: .vertical)
imageView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
containerStackView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
contentView.leadingAnchor.constraint(equalTo: containerStackView.leadingAnchor),
contentView.trailingAnchor.constraint(equalTo: containerStackView.trailingAnchor),
contentView.topAnchor.constraint(equalTo: containerStackView.topAnchor),
contentView.bottomAnchor.constraint(equalTo: containerStackView.bottomAnchor),
verticalStackView.heightAnchor.constraint(equalTo: containerStackView.heightAnchor),
padding1.heightAnchor.constraint(equalToConstant: 10),
padding2.heightAnchor.constraint(greaterThanOrEqualToConstant: 10),
])
}
}
let cell = MyCell(frame: CGRect(x: 0, y: 0, width: 320, height: 110))
cell.backgroundColor = .white
cell.createSubViews()
cell.categoryLabel.text = "MY CUSTOM LABEL"
cell.titleLabel.text = "This is my title"
cell.timeLabel.text = "3 days ago"
cell.imageView.image = UIGraphicsImageRenderer(size: CGSize(width: 110, height:110)).image { (context) in
UIColor.blue.set()
UIRectFill(.infinite)
}
PlaygroundPage.current.liveView = cell
The problem is the vertical stack view. You apparently want to say: the middle label's top should hug the MyCustomLabel bottom, but the 3 Days Ago bottom should hug the overall bottom. That is not something you can say to a stack view.
And even if that is not what you want to say, you would still need to make the vertical stack view take on the full height of the cell, and how are you going to do that? In the code you showed, you don't do that at all; in fact, your stack view has zero size based on that code, which will lead to all sorts of issues.
I would suggest, therefore, that you just get rid of all the stack views and just configure the layout directly. Your layout is an easy one to configure using autolayout constraints.

Why does resizing a label require a delay to update as expected when coming from NotificationCenter?

I'm in the process of adding dynamic type to my app and I'm trying to update the frame of a programmatically created UILabel when the UIContentSizeCategoryDidChangeNotification notification is fired through the following code:
private func configureNotificationCenter() {
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange) , name: NSNotification.Name("UIContentSizeCategoryDidChangeNotification"), object: nil)
}
#objc private func contentSizeCategoryDidChange() {
self.delegate?.didChangeContentSize()
}
and then in the view where the UILabel is going to be updated, I update the frame:
func didChangeContentSize() {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: {
self.label.sizeToFit()
})
}
For some reason, the frame is not set properly without calling DispatchQueue.main.asyncAfter .... At first, I tried calling DispatchQueue.main without the 0.1 second delay since I know UI updates should always be on the main thread, but it didn't seem to make any difference.
While delaying 0.1 seconds isn't a huge deal and I don't think any users would notice, it would be great to understand what's going on and why the delay is necessary.
Edit: Here's how I'm creating the label
label = UILabel(frame: CGRect(x: 0, y: 100, width: view.frame.width, height: 200))
label.backgroundColor = .red
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
label.text = "Test title that should resize"
label.adjustsFontForContentSizeCategory = true
label.textAlignment = .center
let userFont = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title1)
let pointSize = userFont.pointSize
let customFont = UIFont(name: "AvenirNext-DemiBold", size: pointSize)
label.font = UIFontMetrics.default.scaledFont(for: customFont!)
label.sizeToFit()
view.addSubview(label)
This sounds very much like an Auto Layout issue. When you don't delay, Auto Layout is adjusting the intrinsic size of the label and running after you modify the frame for the label, so your sizeToFit comes too early and uses the previous intrinsic size.
When you delay by 0.1 seconds, Auto Layout runs first and sets the intrinsic size of the label, and then your sizeToFit() call uses that new intrinsic size to set the frame.
Use Auto Layout
Make things easier on yourself by using Auto Layout. Instead of messing with frame sizes, sizeToFit, and notifications, just set constraints for the leading, trailing, and top edges of your label and Auto Layout will automatically resize your label when the font size changes:
label = UILabel()
label.backgroundColor = .red
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
label.text = "Test title that should resize"
label.adjustsFontForContentSizeCategory = true
label.textAlignment = .center
let userFont = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title1)
let pointSize = userFont.pointSize
let customFont = UIFont(name: "AvenirNext-DemiBold", size: pointSize)
label.font = UIFontMetrics.default.scaledFont(for: customFont!)
view.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
label.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
label.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
label.topAnchor.constraint(equalTo: view.topAnchor).isActive = true

The following label is truncated?? . Any suggestion how to display MultiLine UILabel?

UILabel does not wrap and shows more than one line.
According to the docs, my text should wrap on word boundary and be displayed in 2 lines. However, this does not occur. I'm using Swift 4 and the latest version of XCode.
let instruction = UILabel()
instruction.text = "Click And Touch Number To Make A Choice"
instruction.backgroundColor = .white
instruction.textColor = .black
instruction.font = UIFont.systemFont(ofSize: 20)
instruction.lineBreakMode = .byWordWrapping
instruction.textAlignment = .left
instruction.numberOfLines = 0
instruction.sizeToFit()
The label to wrap should have a frame whether with frame layout by setting width value or by auto layout by setting leading and trailing constraints that makes the label know it's boundaries and wrap when hitting the right most boundary to another line and so on according to it's content
let instruction = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
instruction.text = "Click And Touch Number To Make A Choice"
instruction.backgroundColor = .white
instruction.textColor = .black
instruction.font = UIFont.systemFont(ofSize: 20)
instruction.lineBreakMode = .byWordWrapping
instruction.textAlignment = .left
instruction.numberOfLines = 0
instruction.sizeToFit()
self.view.addSubview(instruction)
instruction.center = self.view.center
According to the docs:
In some cases, if a view does not have a superview, it may size itself to the screen bounds.
But in your case it doesn't. You just need to constrain label's width somehow and sizeToFit() wouldn't be even needed (Auto Layout will do its job) e.g.
instruction.translatesAutoresizingMaskIntoConstraints = false
instruction.widthAnchor.constraint(equalToConstant: 200.0).isActive = true

Two Line Prompt - Swift

Is there a way to make a two line prompt for a swift navigation bar? I currently cannot find a property to modify. The text I am currently displaying in the prompt comes from an external data model, so sometimes there is more text than fits on the screen. Thanks.
Image Showing Text Outside of Frame
You can try like this:
Swift 3.0
let label = UILabel(frame: CGRect(x:0, y:0, width:350, height:50)) //width is subject to change, Defined as per your screen
label.backgroundColor =.clear
label.numberOfLines = 2
label.font = UIFont.boldSystemFont(ofSize: 16.0)
label.textAlignment = .center
label.textColor = UIColor.white
label.text = "Your Text here"
self.navigationItem.titleView = label
Navigation bar has a title and a prompt
navigationItem.title = "Title, large"
navigationItem.prompt = "One line prompt, small text, auto-shrink"
Having a prompt could be better that having a custom title view, because it gives you more height and it works great with searchbars. But make sure this is really what you want, since the code bellow is not tested on all devices iOS versions. This will just give you an idea how you can control almost anything regarding layout in the navigation bar
class MyNavigationBar: UINavigationBar {
func allSubViews(views: [UIView]) {
for view in views {
if let label = view as? UILabel, label.adjustsFontSizeToFitWidth {
if label.numberOfLines != 2 { //this is the promp label
label.numberOfLines = 2
let parent = label.superview
parent?.frame = CGRect(x: 0, y: 0, width: parent!.bounds.width, height: 44)
parent!.removeConstraints(parent!.constraints)
label.removeConstraints(label.constraints)
label.leadingAnchor.constraint(equalTo: parent!.leadingAnchor, constant: 20).isActive = true
label.trailingAnchor.constraint(equalTo: parent!.trailingAnchor, constant: -20).isActive = true
label.topAnchor.constraint(equalTo: parent!.topAnchor).isActive = true
label.bottomAnchor.constraint(equalTo: parent!.bottomAnchor).isActive = true
}
return
}
self.allSubViews(views: view.subviews)
}
}
override func layoutSubviews() {
super.layoutSubviews()
allSubViews(views: self.subviews)
}
}
To use your navigation bar use:
let navVc = UINavigationController(navigationBarClass: MyNavigationBar.self, toolbarClass: nil)

Get UITextView dynamic height with auto layout after setting text

I have a UITextView not scrollable with auto layout set by interface builder, and the text increase or decrease dynamically with no problem, but i want know what is the new UITextView height after setting text, i'm trying to do this:
NSLog(#"text before: %.2f",self.myText.frame.size.height);
[self.myText setText:self.string];
NSLog(#"text after: %.2f",self.myText.frame.size.height);
this is the result:
text before: 47.50
text after: 47.50
the text is increased in the view when i run it, but the size is the same, how i can get the real height after setting text?
All you have to do is:
set up all your constraints except the height one AND
set textView's scrollEnabled property to NO
The last part is what does the trick.
Your text view will size automatically depending on its text value.
If you prefer to do it all by auto layout:
In Size Inspector:
Set Content Compression Resistance Priority Vertical to 1000.
Lower the priority of constraint height for your UITextView. Just make it less than 1000.
In Attributes Inspector:
Uncheck Scrolling Enabled.
I have used the code given on following link AutoLayout with Dynamic UITextView height and it worked for me :)
This should work:
NSLog(#"text before: %.2f",self.myText.frame.size.height);
[self.myText setText:self.string];
[self.myText layoutIfNeeded]; // <--- Add this
NSLog(#"text after: %.2f",self.myText.frame.size.height);
Here's an example implementation on my Github: https://github.com/guillaume-algis/SO-27060338
Swift 3.0
textView.isScrollEnabled = false
This allow AutoLayout to do its job.
Use below code:
Objective-C Code
[textView setScrollEnabled:NO];
Swift Code
textView.isScrollEnabled = false
Just after changing the text call
[self.myText sizeToFit];
Unlike UILabel, UITextView's has no intrinsic size property. So how I did it was set up the UITextView's height constraint, hook it via IBOutlet, and change its value in textViewDidChange or when text changes.
#IBOutlet weak var textViewHeight: NSLayoutConstraint!
func textViewDidChange(textView: UITextView) {
// dynamic height adjustments
var height = ceil(textView.contentSize.height) // ceil to avoid decimal
if height != textViewHeight.constant { // set when height changed
textViewHeight.constant = height
textView.setContentOffset(CGPointZero, animated: false) // scroll to top to avoid "wrong contentOffset" artefact when line count changes
}
}
- (void)textViewDidChange:(UITextView *)textView
{
UIFont *myFont = [UIFont systemFontOfSize:14];
CGSize size = [self sizeOfText:textView.text widthOfTextView:TextviewWidth withFont:myFont];
NSLog(#"Height : %f", size.height);
}
-(CGSize)sizeOfText:(NSString *)textToMesure widthOfTextView:(CGFloat)width withFont:(UIFont*)font
{
CGSize ts = [textToMesure sizeWithFont:font constrainedToSize:CGSizeMake(width-20.0, FLT_MAX) lineBreakMode:NSLineBreakByWordWrapping];
return ts;
}
select textview and uncheck "Scrolling enabled"
select textview from top menu "Editor > size to fit content"
select the view below it, set its top constraints with the textview bottom to whatever margin you want, then go to "Size Inspector",double click or edit the constraint you just added, and set the "Relation" to "Greater than or Equal"
Yet another approach is to use
myTextView.textContainer.heightTracksTextView = true
Which allows scroll to be enabled
Well, I haven't converted this code into swift4 syntax, but the logic will remain the same. This is an extension method for Xamarin.ios(C#).
public static nfloat GetEstimateHeight(this UITextView textView, UIView View)
{
var size = new CoreGraphics.CGSize(View.Frame.Width, height: float.PositiveInfinity);
var estimatedSize = textView.SizeThatFits(size);
return estimatedSize.Height;
}
The logic here that will work for swift is
var size = new CoreGraphics.CGSize(View.Frame.Width, height: float.PositiveInfinity);
var estimatedSize = textView.SizeThatFits(size);
var textViewFinalHeight = estimatedSize.Height;
Just an addition as per #Pavel Gurov's answer. If you already set up your height constraint, simply make it inactive. Also worth to call .sizeToFit() afterwards to make sure resize action is performed.
theTextViewHeightConstraint.isActive = false
theTextView.isScrollEnabled = false
theTextView.text = "some text"
theTextView.sizeToFit()
the textview height increase by using pure swift code design. I am just do coding part only.
I take this idea from
https://stackoverflow.com/a/45071002/9110213
First thing create the textView
import UIKit
class TextFieldCell: UITableViewCell {
lazy var btnEdit: UIButton! = {
let button = UIButton()
button.translatesAutoresizingMaskIntoConstraints = false
button.addTarget(self, action: #selector(self.actionEdit(_:)), for: .touchUpInside)
button.setTitle("Edit", for: .normal)
button.titleLabel?.font = UIFont(name: "ProximaNova-Medium", size: 18)
button.setTitleColor( UIColor(red: 0.29, green: 0.56, blue: 0.89, alpha: 1), for: .normal)
button.titleLabel?.textAlignment = .left
return button
}()
lazy var separatorView: UIView! = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
lazy var textView: UITextView! = {
let textView = UITextView.init(frame: .zero)
textView.translatesAutoresizingMaskIntoConstraints = false
textView.delegate = self
textView.isScrollEnabled = false
return textView
}()
lazy var titleLabel: UILabel! = {
let label = UILabel(frame: CGRect(x: 27, y: 318, width: 27, height: 12))
label.text = "Name"
label.font = UIFont(name: "ProximaNova-Medium", size: 10)
label.textColor = UIColor(red: 0.61, green: 0.61, blue: 0.61, alpha: 1)
label.textAlignment = .left
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
deinit {
self.titleLabel = nil
self.textView = nil
self.separatorView = nil
self.btnEdit = nil
}
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.selectionStyle = .none
self.addView()
self.setConstraint()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
extension TextFieldCell {
func addView(){
self.contentView.addSubview(self.btnEdit)
self.contentView.addSubview(self.titleLabel)
self.contentView.addSubview(self.textView)
self.contentView.addSubview(self.separatorView)
}
func setConstraint(){
// This part is very important to increase the textview height dyamically
let textViewHeight = self.textView.heightAnchor.constraint(equalToConstant: 27)
textViewHeight.priority = .defaultHigh
self.textView.setContentCompressionResistancePriority(.required, for: .vertical)
self.textView.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
NSLayoutConstraint.activate([
self.titleLabel.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor, constant: 27),
self.titleLabel.topAnchor.constraint(equalTo: self.contentView.topAnchor, constant: 38),
self.textView.topAnchor.constraint(equalTo: self.titleLabel.bottomAnchor, constant: 9),
self.textView.leadingAnchor.constraint(equalTo: self.titleLabel.leadingAnchor),
textViewHeight,
self.textView.trailingAnchor.constraint(equalTo: self.btnEdit.leadingAnchor, constant: -25),
self.btnEdit.centerYAnchor.constraint(equalTo: self.textView.centerYAnchor),
self.btnEdit.widthAnchor.constraint(equalToConstant: 40),
self.btnEdit.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor, constant: -33),
self.separatorView.topAnchor.constraint(equalTo: self.textView.bottomAnchor, constant: 10),
self.separatorView.heightAnchor.constraint(equalToConstant: 1),
self.separatorView.bottomAnchor.constraint(equalTo: self.contentView.bottomAnchor),
self.separatorView.leadingAnchor.constraint(equalTo: self.contentView.leadingAnchor, constant: 27),
self.separatorView.trailingAnchor.constraint(equalTo: self.contentView.trailingAnchor, constant: -15),
])
}
}
extension TextFieldCell {
#objc func actionEdit(_ sender: UIButton) {
}
}
extension TextFieldCell: UITextViewDelegate {
func notifyViewController(text:String){
}
func textViewDidEndEditing(_ textView: UITextView) {
}
}

Resources