قالب وردپرس درنا توس
Home / IOS Development / # 280: Liquid text around images with exclusion paths 🖊 – Little Bites of Cocoa

# 280: Liquid text around images with exclusion paths 🖊 – Little Bites of Cocoa



Subjects

Topics

Text is a large part of iOS apps . Today, we are looking for a way that we can polish the text in our apps by allowing it to flow naturally around objects. Let us begin.

We start with a "before" image. Here we have a basic layout with some text and a image in the upper right corner. Nothing too fancy here, just a common UITextView and UIImageView :

  la    imageView    =    UIImageView   (  image [1
9659010]]:
UIImage ( entitled : "steve" )) la textView = UITextView ] ([19659011] [19659000]] null ) textView . text = "Here are the crazy ..."

]

This looks great. But our text is unnecessarily narrow. It would be great if we could make the text expand to the full width of the device. We change the text view layout as it does:

Well, we will come closer. Now, we only need a way to make the text "flow" or "wrap" around our image. We start by getting the frame by image view and we will make a lane from:

  la    imagePath [19659000]] [19659000] ]       rect :    ImageView .   frame ) 

Finally, we will put our new lane as one of exclusion paths of the text view text containers :

  text display .   textContainer .   exclusion paths    =    [  ImagePath ] 

Success! Since exclusion paths are an Array we can flow text around as many figures as we want!

]


Source link