Stop text in a label with changing numbers from changing width in swift IOS
After checking out monospaced fonts after a tip from @Yuri i have found a solution.
Here is an another question that shows you have to add monospace to a label in IOS 9, that i successfully fixed my problem with.
Labels Disappearing in Swift
In your code snippet, I don't see you adding the speedLabelValue
:
speedLabelValue.fontSize = 30
speedLabelValue.fontColor = UIColor.whiteColor()
speedLabelValue.text = "v"
speedLabelValue.position = CGPoint(x: width, y: height*2-120)
addChild(speedLabelValue)
Nor do I see you adding your impulseLabelValue
impulseLabelValue.fontSize = 30
impulseLabelValue.text = "g"
impulseLabelValue.position = CGPoint(x: width, y: height*2-210)
addChild(impulseLabelValue)
But, in my case, when I added those two labels, it updated fine.
I also initialize those two labels by calling the .ValueChanged
methods manually once:
speedSlider(sliderDemo)
gravitySlider(gravityDemo)
UILabel Disappear From Static UITableViewCell with Dynamic Type
I had the same problem and wanted to solve this without code. So I changed
- the static cell type from basic to custom,
- added my own label
- added leading, trailing and vertical center constraints,
- set the dynamic type check box on the label to on
- and the font of the label to text styles body. -
This works even for table views that have no program code / class
UILabel is not auto-shrinking text to fit label size
In case you are still searching for a better solution, I think this is what you want:
A Boolean value indicating whether the font size should be reduced in order to fit the title string into the label’s bounding rectangle (this property is effective only when the numberOfLines
property is set to 1).
When setting this property, minimumScaleFactor
MUST be set too (a good default is 0.5).
Swift
var adjustsFontSizeToFitWidth: Bool { get set }
Objective-C
@property(nonatomic) BOOL adjustsFontSizeToFitWidth;
A Boolean value indicating whether spacing between letters should be adjusted to fit the string within the label’s bounds rectangle.
Swift
var allowsDefaultTighteningForTruncation: Bool { get set }
Objective-C
@property(nonatomic) BOOL allowsDefaultTighteningForTruncation;
Source.
iOS - trying to rotate a text label and the label disappears
I am not 100% sure if it works or not but why are you not using M_PI_2
. It's just simple thought that you are assuming Value of Pi
to be 3.14
but the exact value is 3.14159...
I did it like this and it worked fine :
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 70)];
lbl.text = @"New";
lbl.backgroundColor = [UIColor clearColor];
lbl.textColor = [UIColor whiteColor];
lbl.highlightedTextColor = [UIColor blackColor];
lbl.font = [UIFont systemFontOfSize:12];
lbl.transform = CGAffineTransformMakeRotation(M_PI_2);
[self.view addSubview:lbl];
You can also check Answers from these Questions :
How to Render a rotated UIlabel
Rotating UILabel at its center
Hope it will be helpful for you.
UILabel disappears in StackView when there is too much content
Just so people know how I fixed this, I was attempting to use one cell template which would handle two different kinds of cells. That is a mistake, instead use the information in this link
Using Auto Layout in UITableView for dynamic cell layouts & variable row heights to properly create two cell templates. I also found this code guaranteed that the cells were properly displaying the titles:
// Keeps the title text always showing
override func didMoveToSuperview() {
super.didMoveToSuperview()
layoutIfNeeded()
}
how to show text as much bigger size as like magnifier
you can use SwiftPopTipView in the following way with your collection view's cell:
func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
println("did select cell \(indexPath.row)")
let cell = collectionView.cellForItemAtIndexPath(indexPath)
let popTip = SwiftPopTipView()
popTip.animation = .Slide
popTip.popColor = UIColor.whiteColor()
popTip.textColor = UIColor(netHex: 0x474747)
popTip.dismissTapAnywhere = true
popTip.message = "Test poptip" //***YOUR TEXT GOES HERE***
popTip.presentAnimatedPointingAtView(cell!, inView: collectionView, autodismissAtTime: 1.5)
}
I hope it works for you. Happy coding!
Related Topics
Split Uint32 into [Uint8] in Swift
How to Cast a Uint64 to an Int64
Modal View Closes When Selecting an Image in Uiwebview iOS
Ui Testing Failure - Neither Element Nor Any Descendant Has Keyboard Focus on Textview
How to Implement iOS 11's Mkusertrackingbutton
Why Does Swift Not Allow Stored Properties in Extensions
How to Request a Desktop Version of a Webpage Using Uiwebview in Swift 3.0
Declaring and Using Custom Attributes in Swift
Swift 2: !, ? -" Value of Optional Type "..." Not Unwrapped"
How to Get Iobluetoothdevice's Battery Level, Using Swift and Appkit (Xcode for MACos)
iOS 13: Threading Violation: Expected the Main Thread
Mutating Function Inside Class
Show Nsmenu Only on Nsstatusbarbutton Right Click
Why Does Swiftui Uihostingcontroller Have Extra Spacing
Using Compiler Variables in Swift