![]() Please note that other Pearson websites and online products and services have their own separate privacy policies. This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site. You might be doing such performance-critical work that even the negligible overhead of maintaining the extra UIView object makes a measurable difference (although in that case, you’ll probably want to use something like OpenGL for your drawing anyway).īut these cases are rare, and in general, layer-backed views are a lot easier to work with than hosted layers.You might be working with multiple CALayer subclasses (see Chapter 6, “Specialized Layers”) and have no desire to create new UIView subclasses to host them all.You might be writing cross-platform code that will also need to work on a Mac.You might still want to use a hosted CALayer instead of a layer-backed UIView in a real-world application for a few reasons, however: The benefit of using a layer-backed view instead of a hosted CALayer is that while you still get access to all the low-level CALayer features, you don’t lose out on the high-level APIs (such as autoresizing, autolayout, and event handling) provided by the UIView class. (In Mac OS 10.8, the performance of NSView is greatly improved, as well.) But the lightweight UIView class in iOS barely has any negative impact on performance when working with layers. On Mac OS, prior to version 10.8, a significant performance penalty was involved in using hierarchies of layer-backed views instead of standalone CALayer trees hosted inside a single view. ![]() Although it is possible to add layers in this way, more often than not you will simply work with views and their backing layers and won’t need to manually create additional hosted layers. As Listing 1.1 shows, you can explicitly create standalone layers and add them directly as sublayers of the backing layer of a view. layer view has only one backing layer (created automatically) but can host an unlimited number of additional layers. create sublayer CALayer *blueLayer = īlueLayer. Adding a Blue Sublayer to the View #import "ViewController.h" #import ViewController ( nonatomic, weak) IBOutlet UIView ViewController You can create a CGColor directly using Core Graphics methods if you prefer, but using UIColor saves you from having to manually release the color when you no longer need it. The CALayer backgroundColor property is of type CGColorRef, not UIColor like the UIView class’s backgroundColor, so we need to use the CGColor property of our UIColor object when setting the color. A small blue CALayer nested inside a white UIView Using VerticalPager or HorizontalPager enables similar functionality to the ViewPager in the view system.Figure 1.5. Swipe through content with the new Pager composableĬompose now includes out-of-the-box support for vertical and horizontal paging between different content. It also improves the performance of modifiers and fixes a number of bugs. This release contains new features like Pager and Flow Layouts, and new ways to style your text, such as hyphenation and line-break behavior. ![]() Today, as part of the Compose March ‘23 Bill of Materials, we’re releasing version 1.4 of Jetpack Compose, Android's modern, native UI toolkit that is used by apps such as and Airbnb. Posted by Jolanda Verhoef, Android Developer Relations Engineer ![]()
0 Comments
Leave a Reply. |