4

I have a UILabel I want rotated 180 degrees, so the text appears upside down. I did some searching and found this question that covers rotations with CGAffineTransformMakeRotation.

Is there a way to rotate it right on my UIStoryboard? The label is always going to appear with that same fixed rotation, so it would be nice to have it just show up the same way in my storyboard as it does when running. I found this post saying it's impossible, but that's a pretty old post (I think pre-storyboard). Of course if it's not with a storyboard, I can just use CGAffineTransformMakeRotation like in the other question I linked in my viewDidLoad.

Community
  • 1
  • 1
GeneralMike
  • 2,951
  • 3
  • 28
  • 56
  • You can look on my answer here: [https://stackoverflow.com/a/63050468/4036390](https://stackoverflow.com/a/63050468/4036390) To find out how to do this – Oz Shabat Jul 23 '20 at 08:54

1 Answers1

7

No, there's no way to do that; you have to apply the transform in code (and, as you say, viewDidLoad is a good place).

The storyboard/nib editor is remarkably good, but there is still a lot of stuff you can do to a view that you can do only in code, and that applies to specific UIView subclasses as well. And of course you can't access a view's underlying layer in the storyboard/nib editor at all either; for example, you can't give the view rounded corners in the storyboard/nib.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Yeah, that's what I was afraid of. Thanks for confirming. – GeneralMike Apr 18 '13 at 15:43
  • It's really not a bad thing. You get used to the interplay of storyboard/nib and code. Code is good! Indeed, I often write entire apps with no storyboard/nib at all. For Mac OS X one is warned not to try to do that, but on iOS it is quite do-able. – matt Apr 18 '13 at 16:18
  • 2
    It kinda flies directly against WYSIWYG philosophy tho. I expect to be able to do everything that deals with the interface in one place, and everything that deals with the actual functionality in another. The interplay you speak of really mucks things up, especially if you haven't been doing this for a long time and you don't "just know" where everything is supposed to be done. – GeneralMike Apr 18 '13 at 17:43
  • But a nib/storyboard is *not* WYSIWYG. It is just a set of instructions for instantiating some objects, exactly as you would do it in code. That's my whole point. Nibs are not some sort of magic. They are object instantiation / initialization / configuration by other means. – matt Apr 18 '13 at 17:55
  • 1
    Sorry to keep rattling on! But I want to add one more thing: your comment is an example of why I dislike storyboards. They mislead the beginning user into believing in a kind of magic that isn't actually there. They actually *hide* what is really going on. In my view it is better to use nibs than storyboards, and better to use code than nibs, especially for the beginner, so that you learn is really happening. (And that is why my book is structured the way it is.) – matt Apr 18 '13 at 17:58
  • I guess we just have different points of view then. Fair enough. This probably isn't a suitable place to continue this discussion though. – GeneralMike Apr 18 '13 at 18:09
  • You can now create rounded corners in the storyboard: http://stackoverflow.com/questions/34215320/use-storyboard-to-mask-uiview-and-give-rounded-corners – Crashalot Dec 20 '15 at 21:09
  • @Crashalot You're right, and in fact that was always true. And now that we have `IBInspectable` properties it's even easier. – matt Dec 21 '15 at 00:35