Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Narendar Singh

macrumors member
Original poster
Please see attached image for the reference, I have a problem with sizeToFit() function in UILable.
 

Attachments

  • sizeToFit.png
    sizeToFit.png
    6.6 KB · Views: 235
The origin of the coordinate system is on the left. The position of any view is based on the left (for the x component of position) Size to fit changes the size but not the position of the component. So the behaviour is exactly what you should expect: position unchanged and size changed.

For sizeToFit: to do what you are expecting it would have to change the position as well as the size.
 
The origin of the coordinate system is on the left. The position of any view is based on the left (for the x component of position) Size to fit changes the size but not the position of the component. So the behaviour is exactly what you should expect: position unchanged and size changed.

For sizeToFit: to do what you are expecting it would have to change the position as well as the size.

Yes I want to change position too. What should I do now?

dejo: I'll update soon.
 
How can I do that?

In Xcode 4:

Xcode -> Preferences -> Downloads -> Components -> Check and Install Now saying "No updates available"

Do you have Xcode 4.5 DP? Also, be aware that auto-layout will only work in apps targeted for iOS 6+.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.