Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Mohamed Moukhtar
Courses Plus Student 6,151 PointsCGAffineTransformScale and Auto layout constraints
I have two UIViews arranged using IB and all their constraints are built correctly. I am trying to use "CGAffineTransformScale" to change the scale of a UIView; my problem is after scaling the view I can't find any way to update my AL constraints.
I used view.updateConstraintsIfNeeded(), view.setNeedsDisplay(), view.layoutIfNeeded(), and view.setNeedsLayout() but no matter what I do I can't figure out a way to update my screen.
I really hope that someone would help to find a solution to my problem.
my code is:
view2.transform = CGAffineTransformTranslate(view2.transform, -view2.bounds.width/2, -view2.bounds.height/2)
view2.transform = CGAffineTransformScale(view2.transform, 2, 2)
view2.transform = CGAffineTransformTranslate(view2.transform, view2.bounds.width/2, view2.bounds.height/2)
view2.contentScaleFactor = 1
view2.layer.borderColor = UIColor.blackColor().CGColor
view2.layer.borderWidth = 1
view.updateConstraintsIfNeeded()
view.setNeedsDisplay()
view.layoutIfNeeded()
view.setNeedsLayout()