I know after ios6, setAttributeString could help to change the line space,
but if I'm typing in the textview, may I change the line space, on ios7 setAttributeString seems work but not on iOS 6
I think you can't change line space of textfield in iOS 6 because there is no API call available for iOS 6. Although you can use core text for this. Look this code for this https://github.com/mattt/TTTAttributedLabel
There was a bug in iOS 6, that causes line height to be ignored when font is set. See answer to NSParagraphStyle line spacing ignored and longer bug analysis at Radar: UITextView Ignores Minimum/Maximum Line Height in Attributed String.
Related
I have a label which shows the pink area on the screen. However, the word "gender " is not shown in the top line even if it has enough space. Why is it not showing up in the first line itself? What I need
label.text = #"Do you believe in gender equality";
Label
The UILabel is working as intended by preventing an orphaned word so it’s more readable. This was introduced in iOS 11. Apple must disable it for iMessage because they probably intend this behaviour for long articles of text, not text messages.
I've seen fixes including
call sizeToFit on the label after the text has been set
setting UserDefaults.standard.set(false, forKey: "NSAllowsDefaultLineBreakStrategy") // Using this private tricky shortcut may leads appstore rejection.
But none of these are working on iOS 13, simulator (Not tested on devices).
Fix
One tricky solution is - append some spaces or two tabs("\t\t") to the text and set programatically.
Use following code:
label.lineBreakStrategy = []
I believe this began with iOS 9 but it may also have been one of the later releases of iOS 8. Basically, numberpad pops up but the actual characters on each button are gone (1-9, 0). I've truncated the top half of this image for confidentiality:
I had the same issue when setting the keyboard type in IB. But setting it programatically in the viewDidLoad method solved the issue for me (see my answer on another thread).
My problem is that I have to two UITextView displaying different Text, but always the same number of characters. I could not find a way to set a fix character-width and space width in UITextView/NSAtrrStr/UIFont.
Is there a way to do that?
thanks
As far as I know, Courier New is the only fixed-width font shipped with iOS.
Also, you can always import custom fonts to your xcode project which you know are fixed-width. Here is how: Embed Custom Font in iOS
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.
sizeWithFont:forWidth:lineBreakMode:
has been deprecated in iOS7. I'm not sure how to include line breaks when using sizeWithAttributes.
Does anyone know of a good workaround? I'm trying to determine the expected height of an nsstring with given font and line break mode and width.
https://developer.apple.com/library/ios/documentation/uikit/reference/NSString_UIKit_Additions/DeprecationAppendix/AppendixADeprecatedAPI.html
sizeWithFont:forWidth:lineBreakMode:
Returns the size of the string if it were to be rendered with the specified font and line attributes on a single line. (Deprecated in iOS 7.0. Use boundingRectWithSize:options:attributes:context:.)