0

I'm trying to work our if it's possible to display text in a Shape so that the text it not rectangular but the same as the shape it's self.

I have tried

    Text(loremIpsum)
        .font(Font.system(size: 14))
        .clipShape(Circle())

which the result was that I'm not seeing new lines when text reaches the edge of the shape.

circular text which doesn't have all the text visbile

I then tried to use the circle first and add text to that but that resulted in text appearing outside the circle.

    Circle()
        .stroke(Color.black, lineWidth: 2)
        .padding(6)
        .overlay(
            Text(loremIpsum)
            .font(Font.system(size: 14))
        )

circle with text appearing from the side

I'm wanting to achieve Text that fits perfectly into whatever Shape I use. Is this possible?

The question suggested here does not answer my question sadly. hat just fits text into a Shape but still retains a rectangular frame. I'm trying to make text exactly match the shape I am placing it in.

StartPlayer
  • 485
  • 4
  • 21
  • You can achieve by UIKit https://stackoverflow.com/a/41613814/14733292 – Raja Kishan Oct 23 '21 at 10:51
  • what I'm trying to do is set myself learning exercises to solve problems in SwiftUI rather than UIKit. Whilst the link looks useful it seems it will be just a circle rather than any `Shape` – StartPlayer Oct 23 '21 at 11:03
  • Does this answer your question? [How to have text fit within boundaries of circular shape/image SwiftUI](https://stackoverflow.com/questions/67029483/how-to-have-text-fit-within-boundaries-of-circular-shape-image-swiftui) – lorem ipsum Oct 23 '21 at 13:09
  • It did not sadly. The text remains in that example the text is still in a rectangle frame and not matching that of the `Shape` I use – StartPlayer Oct 23 '21 at 13:34

0 Answers0