Welcome to the Divkit BaseUI Documentation!
Divkit BaseUI is a powerful framework for building user interfaces in iOS. It provides a collection of easy-to-use components and utilities that enable you to create stunning UIs with minimal effort.
With BaseUI, you can accelerate your iOS app development by leveraging a rich set of pre-built UI components, styles, and animations. This documentation will guide you through the process of using BaseUI to design and customize your app’s user interface.
Getting Started
To get started with BaseUI, follow these steps:
- Install BaseUI using CocoaPods or Swift Package Manager.
- Configure BaseUI in your Xcode project.
- Import BaseUI into your project files.
- Create your first UI using BaseUI components.
Installation
To install BaseUI using CocoaPods, add the following line to your Podfile:
pod 'DivkitBaseUI'
To use Swift Package Manager, add the following dependency to your Package.swift file:
.package(url: "https://github.com/divkit/BaseUI.git", from: "1.0.0")
Once you have installed BaseUI, you are ready to start using it in your project.
Configuration
To configure BaseUI in your Xcode project, follow these steps:
- Open your project in Xcode.
- Navigate to your target’s Build Settings.
- Search for “Other Linker Flags” and add ‘-ObjC’ to the value.
- Search for “Objective-C Bridging Header” and specify the bridging header path (if not already set).
With BaseUI properly configured, you can now import it into your project files and start building your UI.
Usage
BaseUI provides a wide range of UI components and utilities that you can use to create your app’s interface. Here are some of the key features and concepts you should be familiar with:
Components
The BaseUI framework includes a variety of reusable UI components, such as buttons, labels, text fields, etc. These components are designed to be easily customized and styled to fit your app’s design requirements.
Styles
BaseUI provides a set of predefined styles that you can apply to your components. These styles define common UI properties like colors, fonts, and sizes, allowing you to ensure consistent styling across your app.
Animations
BaseUI includes a number of built-in animations that can be used to enhance your app’s user experience. With just a few lines of code, you can add smooth transitions and interactive animations to your UI components.
Utilities
In addition to components and styles, BaseUI offers a set of utility classes and functions to simplify common UI tasks. These utilities can help you with tasks like layout management, input validation, and data formatting.
Examples
To illustrate how to use BaseUI, here are a few examples:
Example 1: Creating a Button
Here’s an example of how to create a custom button using BaseUI:
import BaseUI
let button = BaseButton()
button.setTitle("Click me", for: .normal)
button.style = .primary
view.addSubview(button)
In this example, we create a new instance of the BaseButton class, set its title and style, and add it to a view. That’s it!
Example 2: Applying a Style
Let’s see how to apply a predefined style to a label:
import BaseUI
let label = BaseLabel()
label.text = "Welcome"
label.style = .title
view.addSubview(label)
In this example, we create a new BaseLabel, set its text, apply the ‘title’ style, and add it to a view. The label will automatically inherit the defined properties for the ‘title’ style.
Example 3: Using Animations
BaseUI makes it easy to add animations to your UI components. Here’s an example of animating a view’s opacity:
import BaseUI
let view = BaseView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
view.backgroundColor = .blue
UIView.animate(withDuration: 0.5) {
view.alpha = 0.5
}
In this example, we create a new BaseView with a blue background color. We then animate its opacity to fade out over a half-second duration.
Reference
For comprehensive details on all the available components, styles, animations, and utilities provided by BaseUI, refer to the official documentation: