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:
Related
I am trying to make a feature where a user can see if someone is online or offline. If there are online there is a small green dot on the image, and red if offline.
How can I build this? I have the circle image working but I am not sure how to add the green dot on it.
I am using Storyboards and UINibs. So I assumed I would need to make a UIView, not sure exactly how to place it.
I can build this in Swift UI, so is it possible to buildit in swiftUI, and add that image to a UICollectionView Cell?
Just palce a label with a "." text in it, make the font as big as you would like it to be, apply constrains on it and then just change: myLabel.textColor = UIColor.green / myLalbel.textColor = UIColor.gray or whatever fits you, also note that you can apply centering of the text inside the label.
I went with adding a UIImageView over that image, and used the SFSymbol "circle.fill"
I then used the ternary operator to determine the state.
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.
How i can create a view like in this image in iOS. I need to create a view so that image and the texts should be like that.
Since iOS 7 in UITextView there is textContainer property of type NSTextContainer.
You can set there exclusionPaths property which is an array of UIBezierPath objects that define your images' shapes. The text will float around those shapes. After that simply add an image view in proper place above text view.
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.
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