![]() ![]() ![]() But what are items and attributes? And what is the difference between multiplier and constant? item1.attribute1 = multiplier x item2.attribute2 + constantĪs I mentioned earlier, a constraint describes the relationship between two items in the view hierarchy. The basic blueprint of a constraint looks something like this. The goal of the layout engine is finding a layout that is unambiguous and satisfiable. If the layout engine is unable to find a solution that satisfies every required constraint, the layout is unsatisfiable. If the layout engine finds multiple solutions, the layout is ambiguous. The layout engine inspects the constraints and attempts to find a solution, that is, a layout that fits the constraints. That linear equation is used by the Auto Layout engine to calculate the frames of the views in the view hierarchy. An item can be a view or a layout guide.Įach constraint can be translated into a linear equation. The first thing you need to know about constraints is that each constraint describes the relationship between items in the view hierarchy. By understanding the properties and limitations of constraints, you get a better grasp of how Auto Layout works under the hood. In this tutorial, I would like to zoom in on the anatomy of constraints. The user interface of modern iOS applications is driven by Auto Layout and Apple continues to improve and invest in Auto Layout with every iteration of the platform.Ĭonstraints are the building blocks of user interfaces powered by Auto Layout. If you plan to build an iOS application that look great on any device, then Auto Layout is your only viable option. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |