A set of basic UIKit tools, for Swift iOS app development.
This package offers a few extensions of standard UIKit classes, in order to abstract some of the more common software tasks.
Where to Get
Swift Package Manager
The most common method of integration will almost certainly be via the Swift Package Manager (SPM).
The package can be accessed from GitHub, via the following URIs:
Simply integrate the package into your project, and import the module, in files that use its extensions:
You can also get the package, using Carthage, the general-purpose package manager that is supplied by GitHub.
In order to import the package, add the following line to your cartfile:
If you choose to build the module, you will also need to import the module into files that use the extensions:
Alternatively, the entire set of extensions is available in a single source file, that you can integrate directly into the main module:
With Carthage, this would be available in the
If you do this, then the file would be integrated directly into the main module, so you will not need to
import the file.
Finally, you can simply include the module into your project, using a Git Submodule, which is available, using the two URIs (SSL or HTTPS), referenced above, in the Swift Package Manager section.
If you do this, you should include the source file directly into your project, as outlined in the Carthage section.
How to Use
Once the package has been added to the project, and the module is imported (or the source file is directly integrated into the main module), the extensions immediately become available in the base UIKit classes. The extensions are listed below:
This adds just one method to the standard UIKit UITabBarController Class:
The purpose of this method, is to allow an easy shortcut to customizing the colors of the Tab Bar.
This adds a number of computed properties, and one method, to deal with Responders.
Class Computed Properties
These are defined as “class” properties, so you don’t need an instance to use them.
System State Flag Instance Computed Properties
These are instance properties, as opposed to class properties:
These are only available in instances (not class):
Device Instance Computed Properties
This is a property that returns the aspect of the device screen:
View Hierarchy Instance Computed Properties
This will return the view controller immediately “under” this one, in a navigation stack:
This recursively finds the current selected responder (or nil, if no responder):
This method will also end editing for the view controller:
IBInspectable Computed Instance Properties
Auto Layout Instance Methods
Image Composition Instance Computed Properties
Pixel Information Instance Methods
Sizing Instance Methods
Color Information Instance Computed Properties
Color Computation Instance Methods
The Test Harness App
Because the package is a UIKit extension, unit tests will be less effective than a test harness. We provide a fairly comprehensive test harness app, that not only provides excellent code coverage, but also acts as a template for real-world implementation.
The app is a fairly basic “tabbed” app, that presents 5 tabs; each, corresponding to one of the extended classes:
|Figure 1: UITabBarController||Figure 2: UIViewController||Figure 3: UIView||Figure 4: UIImage||Figure 5: UIColor|
Tab 1 (UIViewController) also has a navigation stack, and allows you to open a second screen, showing access to the previous view controller, and the responder properties:
|Figure 6: UIViewController Navigation Screen||Figure 7: UIViewController Navigation Screen (With Focus)||Figure 8: UIViewController Navigation Screen (Next Screen)|
The app is written as if it were a “shipped” app, and has excellent code quality, localization, and clear implementation. It should be an excellent example of use.
© Copyright 2022, The Great Rift Valley Software Company
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.