-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Swift Essentials (Second Edition) - Second Edition
By :
Although the
xib files offer a mechanism to customize classes, the majority of UIKit views outside of standard frameworks are implemented in custom code. This makes it easier to reason what the intrinsic size should be as well as to receive code patches and understand diffs from version control systems. The downside of this approach is when using Auto Layout, writing the constraints can be a challenge and the intrinsic sizes are often misreported or return the unknown value: (-1,-1).
A custom view can be implemented as a subclass of UIView. Subclasses of UIView are expected to have two initializers, one that takes a frame:CGRect and one that takes a coder:NSCoder. The frame is generally used in code, and the rect specifies the position on screen (0,0 is the top-left) along with the width and height. The coder is used when deserializing from a xib file.
To allow custom subclasses to either be used in Interface Builder or instantiated from code, it...
Change the font size
Change margin width
Change background colour