i am searched in stackoverflow, regarding font problems in ios 9, but nothing to any related solution, so, i am post this question.
Question:
I am using UIStoryBoard to design a page, in this page i have using labels, textfields and extra... , my problem is I have provide "system font size XX" to labels and text fields text (Here i am using XCode 6.3 and iOS 8),
and run in iOS 8 Devices its display exact design(means, the what i am design in storyboard).
but i am run in iOS 9 its font size increases, what the problem.
==> In iOS 8 device, the Label text is displayed exactly what i am design
For example
[] --> let, this is label , here i am design like this,
" [2015] "
Size of Label is: 55
Label text font size : system 17
==> In iOS 9, Here missing the content like this,
" [20...] "
Size of Label is: 55
Label text font size : system 17
So, i am thinking Label font size is increased.
please, suggest any solutions or fixes.
Thanks.
iOS9 now has a new System Font called "San Francisco"
I believe your labels are only fitting for the previous system font "Helvetica", so your labels are truncating the tail.
You can fix this by setting the minimum font size in Interface Builder or via code as such:
let label = UILabel()
label.minimumScaleFactor = 10.0/12.0
You can find more informtion on the new iOS9 system font here: https://developer.apple.com/fonts/
It seems that the font in iOS9 is bigger. If you dont't want to change the font size or set minimumScaleFactor, you can change label.adjustsFontSizeToFitWidth = YES. But you'd better put it at last of label creation code just before you add the label to some view
Related
I am struggling with a basic beginners problem at the moment. My app should run on all the different iPhones. My problem right now is that my constraints are not really responsive.
Examples:
As you can see on the iPhone 11 everything looks perfectly fine but on the iPhone 6s it a bit messed up sometimes.
My question, is there an easy way to make my design responsive? Not just the constraints but also text (e.g. "Main Wishlist" in the 3rd picture).
By the way I am doing everything programmatically. Any help on this is appreciated :)
Using the Dynamic Type you can solve the dynamic font problem
Here is an example of how you can scale your Fonts Automatically based on the content size using the Dynamic Type:
guard let customFont = UIFont(name: "CustomFont-Light", size: UIFont.labelFontSize) else {
fatalError("""
Failed to load the "CustomFont-Light" font.
Make sure the font file is included in the project and the font name is spelled correctly.
"""
)
}
label.font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: customFont)
label.adjustsFontForContentSizeCategory = true
https://developer.apple.com/documentation/uikit/uifont/scaling_fonts_automatically
Using the Auto Shrink Property
follow this accepted answer
Scale text label by screen size
We implemented Dynamic Font type for our iOS native app. We customized the font sizes based on the our custom guidelines.
For example Body text style aEEELarge size is 53. But as per our custom guidelines we restricted maximum font size to 33. We used the following code snippet which is working perfectly.
Code Snippet :
var customFont = UIFont.preferredFont(forTextStyle: UIFontTextStyle.body)
customFont = UIFontMetrics.default.scaledFont(for: customFont, maximumPointSize: 33)
forLabel.font = customFont
So the problem is, Accessibility Inspector is showing the warning as below. even though we enable adjustsFontForContentSizeCategory = true , still we see warning.
If we change the maximumPointSize as 50 the warning is going away. But as per our Guidelines maximum size is 33. Is there any solution to suppress Accessibility Inspector warning ? Please help us if you know the solution.
I am trying to change the font size based on the iPhone Screen size.
I am setting a font size that looks good on iPhone 6 Plus and once I detect the iPhone and it is not iPhone 6 Plus, I change its size.
I am trying it on the ViewDidLoad event:
lblLogin.Font.WithSize(17f);
But it is not updating the FontSize, I guess "Font.WithSize" is not the path to achieve it, any ideas?
WithSize() returns a font reference, it does not modify the existing font
lblLogin.Font = lblLogin.Font.WithSize(17f);
Also, see this Xamarin recipe
If you want to change the font size of a UILabel, try to use those code, like:
//1 Just change size
customLabel.Font = UIFont.SystemFontOfSize (18);
//2 Set the font name and size:
customLabel.Font = UIFont.FromName("Helvetica-Bold", 20f);
Hope it can help you.
I try to clone a placeholder behavior for a tableCell. It must look exactly like the placeholder used within a UITextField. Does anybody know which Font is used by Apple as well as which Font size?
Thanks
The default font in UITextfield is HelveticaNeue 14
I am developing an application that target iOS6+.
I have a text view with with large attributed text. Maybe 1000 lines odd lines red color and other lines green color.
I use below code for changing the font size of the textview:
self.doaTextView.editable= YES;
self.doaTextView.font = [UIFont systemFontOfSize:self.FontSilder.value];
self.doaTextView.editable= NO;
but it takes much time. It is about 2 second on iOS 7 and about 5-10 second on iOS 6!!!
(I enable and disable editable feature, becasue if I do not do this the changes not appear in iOS 6. Please see here)
What is the problem?
Edit
I found this topic related to this problem too. Really there is not any solution for this?
I finally fixed this problem by recreating my attributedtext again and setting it as a new attributedtext to my uitextview.