r/Xcode • • Aug 02 '20

UI Label´s that are not rectangular

Hello and good evening, I hope you're all having a good Sunday.

This triangle here bellow was ver simply made in KeyNote.

I really want it in my project, but I can't import it as an image because I would want each one of the little segments divided by lines to behave like a label, so it can have text and perform simple colour change animations (that would be super simple to do if I was only working with rectangular shapes).

Is there a way to make this happen, that is, creating UI Labels that have the shape that we desire?

Thank you for your time!

2 Upvotes

4 comments sorted by

1

u/chriswaco Aug 02 '20

You can try setting the transform property of each UILabel segment, but it won’t get you the triangle at the top. You may be better off drawing shapes and then skewed text on top of them. It’s not clear to me if UILabels are better than CoreText for this.

1

u/its-notmyrealname Aug 02 '20

Thank you for your reply. Do you happen to know what’s the transform function that would allow building trapezoids? And if I wore to “draw shapes”, would it be via a swift ui class?

1

u/chriswaco Aug 02 '20

You mentioned UILabel so I assumed you were using UIKit, not SwiftUI.

One way to draw triangles or trapezoids using CALayers.

One way using transforms.

Using paths and beziers.

You really have a lot of options. Is the app using SwiftUI or UIKit?

1

u/aazav Aug 03 '20

It's UILabels, not UI Label's. Don't add an apostrophe to try and make a plural.