I have one textfield "A" with width 150. but whenever I am passing more characters to textfield "A", it is getting overlapped on other textfield "B" characters.
I want textfield "A" to be fixed size and scrollable(mostly right and left).
Thanks in advance.
You should use Auto-Layeout in your storybook. Set fixed width, trailing space and leading space to your text field.
I have added the Auto-Layeouts to my textfields and I have followed below steps:
1) Selected the label.
2) Go to attributes inspector.
3) Select 'Line Breaks' and choose an option Truncate Tail
4) now I can see the text without overlapping with another textField.
Note: But still I am not able to view/Scoll the full text.
Just found this piece of code. It might help you
scrollView.hasHorizontalScroller = true
textView.maxSize = NSMakeSize(CGFloat(FLT_MAX), CGFloat(FLT_MAX))
textView.isHorizontallyResizable = true
textView.textContainer?.widthTracksTextView = false
textView.textContainer?.containerSize = NSMakeSize(CGFloat(FLT_MAX), CGFloat(FLT_MAX))
Related
Currently, i'm using the code below but there is a problem that the last part of the text is ... instead of *** (see picture). Now I want to hide text with only six * like ****** and figure out how to fix the problem above.
#objc func hideMoney(){
if isMoneyHide == true{
moneyAmount.isSecureTextEntry = true
}else{
moneyAmount.isSecureTextEntry = false
}
isMoneyHide = !isMoneyHide
}
The result:
Thank in advance
To solve the issue
Set minimum font size to lower than your UITextField text size
Example: - If your UITextField text size is 20 then minimum font size set to 15
i have a tableviewCell containing 2 labels.
The right one has a fixed width and fixed trailing space to superview and the left one a fixed leading space to superview and trailing to right label.
Sometimes i only need the the left label and in this case i want the left one to have a fixed trailing space to superview instead. So, i created a second inactive constraint and do this in my code:
if(entry.right.isEmpty) {
tableCell?.longConstraint.isActive = true
tableCell?.shortConstraint.isActive = false
tableCell?.rightLabel.isHidden = true
} else {
tableCell?.longConstraint.isActive = false
tableCell?.shortConstraint.isActive = true
tableCell?.rightLabel.isHidden = false
}
but when i load the table all displayed cells have the default constraint active and only after scolling out of view and in again, they are displayed correctly.
For an easy way you can embed them inside a horizontal UIStackview and set
self.rightlb.isHidden = true
and it will disappear with no width automatically , also in your current code make sure
tableCell?.layoutIfNeeded()
after you change the constraints
Try adding this code after adjusting constraints programmatically
tableCell?.setNeedsLayout()
tableCell?.layoutIfNeeded()
Hope this works
I have a UITextView that has maxLines set like this:
textView.textContainer.maximumNumberOfLines = 3;
textView.textContainer.lineBreakMode = .byTruncatingTail
textView.isScrollEnabled = false
However, when typing in the textView, you can press return several times and type beyond 3 lines. Visually, only 3 lines appear, but as you type text is being entered on and on. Is there a way to prevent this?
The maximum number of lines is used to define how many will be visible in the interface. This has nothing to do with the amount of text you type.
If you want to add a "limit" to the number of characters you have to do it programmatically.
There are several other answers related to this on SO.
How to limit characters in UITextView iOS
You can try this
textView.textContainer.maximumNumberOfLines = 3
textView.textContainer.lineBreakMode = .byTruncatingTail
textView.layoutManager.textContainerChangedGeometry(textView.textContainer)
I need disable some elements from my chart.
I used the iOS-charts library in (Swift 2), however I can't understand how to disable the following:
Hide right and left numbers
Hide description color square
Hide all vertical lines
self.chartView.xAxis.drawGridLinesEnabled = false
self.chartView.leftAxis.drawLabelsEnabled = false
self.chartView.legend.enabled = false
will do the job
self.chartView.drawEntryLabelsEnabled = false
This will hide the label from PieChart and shows only value. Also shows legend with label texts.
For only hide the top one:
graphCell.lineChartView.leftAxis.drawTopYLabelEntryEnabled = false
I am new to iphone development .I want to wrap up the text in the label.I want to wrap up to a particular position in the label.Thanks.
theLabel.lineBreakMode = UILineBreakModeWordWrap;
theLabel.numberOfLines = 0;
That'll let it wrap an arbitrary number of lines. If you want to limit them, and have it truncate with a “...”, then set the numberOfLines property to that value.
Set "Line breaks" in Interface Builder ( http://drp.ly/d3K65 ) to "Word Wrap" and increase height of the UILabel.
You can do the same thing (or even more complex) in the code, see UILabel reference http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UILabel_Class/Reference/UILabel.html