I would like to embed an image within a block of text. The image would be 1 line high. I am able to drag the image around over the text but I want to be able to insert it between words (with the words wrapping in the textview accordingly)
Any ideas how I can go about this?
Thanks.
You could try to use CoreText, and create text boxes on all four sides of the image.
http://developer.apple.com/mac/library/documentation/Carbon/Conceptual/CoreText_Programming/Introduction/Introduction.html
Related
I am trying to make a square button that is on the smaller side (30x30), and I want to include the amount of participants there are as the text, for some reason the button is cutting the title off on the left and ride sides (see picture) forcing me to either have a bigger button (not ideal) or have really small text (also not ideal). Is there a way to stop it from cutting off?
If you're trying to display one character in that 30*30 button, make the button size large, check screenshots for reference:
Change Button Style Plain into Default.
I am very new to iOS Development. I recently started out on swift and learnt all the basics. This is my first app, so please bear with me if it is a dumb question.
I am trying to do the following.
Have a text input field, where a user can enter a persons name. We then display an image from our storage and a bio in a text view.
So, here's my problem sometimes, the bio text is quite large and is getting truncated. I tried the scrollable option in the attributes panel, but I do not want the image to stay there when I scroll down. I want the image to move up, similar to how it does in a webpage. Anyway I can achieve this or any resource you could point me to?
PS: I have tried using the scroll view, but I feel I am messing something up as it is not working as intended, and is truncating it.
The first picture is my main storyboard. The second one is the attribute panel for my text view.
Please let me know if you need any further details which I did not post here. I don't know what else to post.
Edit:
I am using Auto Layout.
Edit 2:
This is my View Controller Layout.
Edit 3 :
I have tried using a label with 0 lines like Beowulf suggested. But this is what happened.
Edit 4: Updated with the images of constraints and latest result.
Please note that the "Hero Text View" is just a label.
I don't think you need the container view for the text view. Mostly, what you need to do is set the height of the text view based on the content of the text view. Text views don't have an intrinsic size like labels or images. So you should create height constraint for the text view. Create an IBOutlet for it then set it programmatically. After you get the text for the text view say something like:
self.heroTextViewHeightConstraint.constant = self.heroTextView.contentSize.height
This will make it so your text view won't scroll, and, if you setup your scroll view correctly, it will resize to accommodate to fit all of its content.
If you truly don't want the text view to scroll you could just use a UILabel with lines = 0 and word wrapping, and you could avoid having to set any constraints programmatically.
I would suggest loading your text view with attributed text that include the image built-in. That way the image will scroll as part of the text scrolling with no effort from you.
Starting in iOS 7 NSAttributedString has a method that will let you load an RTF file or RTFD file (RTF file with embedded images). The method that creates the attributed string directly from a file URL has been deprecated in iOS 9, but the method initWithData:options:documentAttributes:error: is still supported.
You could create an RTFD file on your Mac that has the text and the image in it. Then drag that file into your project, load the file from your bundle into an NSData object, then use initWithData:options:documentAttributes:error: to load the data into an attributed string object that you can install into your text view.
In my app I have a "summary" paragraph that based on data an user actions in the app changes what it displays. The issue is it displays both regular text and clickable text (like a button) in the same sentence and line. The app will have a series of if else statements and based on the results of these the text that will be displayed is determined, but how do you make some of the text a button tied to an action and some of the text a plain label? Any and all help is appreciated!
In iOS 7, buttons look like blue text. I would suggest taking advantage of that fact.
I would use AutoLayout, and create your fields with constraints that put a very small amount of space between each label and button in your line of text/labels, with a vertical constraint on all of them that aligns their leading to match.
I have UIView which is container for 2 views: UILabel and UIImage. Lets say that UIIlabel is same size as container. If I add UIImage at some position in container, is it possible that text is shown only in empty area where there is no image ?
Something like in word document when you place image, text breaks line whenever it intersects beggining of image. Is this possible in objective c ?
Thanks.
In iOS 7, there is a new framework named Text Kit. Working with Text Kit, you can simply add exclusion paths in UITextView which meet your question.
Here is a Text Kit Tutorial by raywenderlich and some screen shot:
Is there in ios something like android:ellipsize="marquee" like in android?
I need to make text scrolling animation for label but I didn't find a way for doing it.
EDIT:
# Tomasz Wojtkowiak :
many thanks for your recommendations.
PROBLEM:
I have a label with a define width in pixels and the text that should be displayed in this label, and this text have for example double label width. I don't want to clip/wrap/trancate, I need to show the full message. In android for the TextView there is a tag android:ellipsize="marquee" and in the above described case the text in the label will be autoscrolled from left to write(some kind of animation).
How can I do the such behavior in ios?
Thanks in advance.
Kindly try this JHTickerView.
It is an open source project.. It has custom UILabel (UITickerView) that has a property as you expect! that is the label will marquee the given text to the it.