customize leading and kerning in a text view in iPhone application - ios

I am using a UITextView in a iPhone application.I am using custom font.I want to set 32px line spacing in the text view also want to adjust kerning and leading between characters in text view.
Anyone knows about it?
Can the core text framework is helpful? If so, please explain how. How can Incustomize the line spacing in text view in iPhone application?

If you want use Core Text, it has the feature to specify the leading-space of a paragraph, the first line head indent of a paragraph, the line-spacing, underline...
check the docs here

Related

iOS Autoshrink not working on single word in UILabel

Using autolayout to have a multiline UILabel auto size the text to fit does not work for single words.
Here is how storyboard is set up:
Here's the problem.
This does not display properly:
But this does:
I have adjusted every setting in the storyboard. I have changed all of the Line Break settings (wrap, truncate, etc), I have adjusted # of lines, I have made text plain vs attributed, I've changed font sizing and scaling, everything. What am I missing? Why does "California" get cut off instead of shrinking to fit? I've seen many other posts on SO and haven't yet found a solution (which needs to be compatible back to iOS 9)
Your label is being filled both horizontally and vertically until it runs out of space, then it starts shrinking the text to fit. In the one word example it breaks the word into two lines because there is vertical room.
Do you know in advance or can you calculate in the app when you have only one word in this label? If so you can change the number of lines to 1 instead of 0 so the app will keep the contents on one line and shrink this word.

Label not displaying properly

I am beginner in iOS app development, I am working on a project that was done by someone else. So my problem is the label is not fully showing its contents:
check the second column under 'customer name'.
I did some basic alterations to the label but it makes no change at all. This is a collection view, there is another view inside the collection view cell which holds the title label and description label.
I searched everywhere but didn't get any proper answer please help.
Label in iOS does not change its size to suit the contents, you need to adjust it in your code. Your options are either decrease the font size to suit the description label size, or adjust the description label's height/width to make room for current content. I'd do a combination of both (slightly reducing the font size of the label's text, and at the same time making all the cells a bit wider and taller).
Oh, there is also a way to automatically shrink the font size if the contents doesn't fit the space. So, you'd need to check the option for your description label. Here's how you might do it: how to make UILabel autosize text in storyboard (or interface builder), NOT programmatically

UITextview clipping with three dots?

I have a UITextView showing some dynamic content that can vary in size.
The textview has no scrolling allowed and its size is independent from the content.
Given its auto-layout constraints, the text view has a different horizontal size on iphone5 and iPhone6plus for example.
What I would like is my text to be clipped when necessary with 3 dots at the end like that “…”. (there is a "More" UIButton launching safari below the UITextView)
I’m not sure if there is a UITextView property or if i should consider some code that checks how many characters the textview can display in the current circumstances and modify my string to be shown accordingly (cutting and appending #“…”).
Thank you.
Try setting the UITextView line break mode. It works just like UILabel and should use "..." at the end.
self.textView.textContainer.lineBreakMode = NSLineBreakByTruncatingTail;
See https://developer.apple.com/library/ios/documentation/UIKit/Reference/NSTextContainer_Class_TextKit/index.html#//apple_ref/occ/instp/NSTextContainer/lineBreakMode
If you don't need to edit the content of the text view from the user and you are only displaying content, then use UILabel.
above white background it the text view and the text with 4 lines is the UILabel, i assume you are trying to implement something like this.
Only change the line break mode to "Truncate Tail" and set the no of lines to value you desire.

Customize iOS UITextView text

In my iOS application i have an UITextView in which i insert some text downloaded from the web. This text is not editable/selectable by the user and it's a sort of preview of the whole text downloaded.
So, i want to show only the first two line of the text and i want to have always a vertical centered alignment. The text can also have only one line and, if there are more than two lines or there is a very long line i want to put these ".." at the end of the visible text.
I want something like this:
I hope i explained myself.
If it is only a preview of the entire text, you can use a UILabel instead. The UILabel will have a fixed size and it will automatically truncate the text at the end and add the "..." you want. Don't forget to specify the numberOfLines property of UILabel to be 2 and the textAlignment property to NSTextAlignmentCenter if you want it centered.

Reposition images within view based on size of text - iOS

I have been recently getting into iOS development, and I'm trying to build something that looks (very roughly) like this: http://falkendev.com/downloads/ios-sample.png
Basically, it's a page that shows simple text -- large header text that may span multiple lines, a separator line, and then smaller descriptive text that may be a variable length. This text does not need to be editable. I'm working using interface builder, but I imagine that what I want done may need to be done programmatically?
Two questions:
-- How do I go about creating these text fields so that they adjust their height based on the content? I'm assuming I would be using a standard "text" field for each, make them not editable, and then programmatically change their height? And then based on the height of the various text fields, I would need to adjust the positioning of the text fields and the divider line between them?
-- How do I go about making the page scrollable? It's possible that the descriptive text will be long and would extend off the edge of the screen. I would want the whole page to be scrollable, not just the descriptive text section. I'm assuming I would place all my elements within a scroll view... but currently when I do that and view it, the view just gets centered (cutting off both the top and the bottom) and I can't scroll it at all.
Thanks for any help!
set the scrollview content size to greater than its actual size to
make it scrollable like this :
scrollView.contentSize = CGSizeMake(YourWidth ,YourHEight ); // Here you can change either of height and width to make it more scrollable in that direction.
You can use UITextView object to have a scrollable text field...
which can scroll to show additional text..just set its editing
property to NO.
Otherwise to dynamically update label height yourself...use
NSString sizeWithFont method

Resources