Getting Started

v2.3.0

Install TTBaseUIKit and configure your iOS project in under 5 minutes. Supports SPM, CocoaPods, Carthage, and manual integration.


📦 Installation

Swift Package Manager (Recommended)

The easiest way to add TTBaseUIKit:

  1. Go to FileAdd Packages... in Xcode
  2. Enter the repository URL
  3. Choose "Up to Next Major" with version 2.3.0 or higher
// Package.swift
dependencies: [
    .package(url: "https://github.com/tqtuan1201/TTBaseUIKit.git",
             .upToNextMajor(from: "2.3.0"))
]

// Or use the master branch:
dependencies: [
    .package(url: "https://github.com/tqtuan1201/TTBaseUIKit.git",
             branch: "master")
]

CocoaPods

Add to your Podfile:

pod 'TTBaseUIKit'

Carthage

Add to your Cartfile:

github "tqtuan1201/TTBaseUIKit"

Manual

  1. Put TTBaseUIKit repo somewhere in your project directory
  2. In Xcode, add TTBaseUIKit.xcodeproj to your project
  3. On your app's target: add as an embedded binary on General tab, and as a target dependency on Build Phases tab

⚙️ Basic Configuration

Configure TTBaseUIKit in your AppDelegate.swift. The framework uses 5 config objects:

Config Objects: ViewConfig (colors), SizeConfig (dimensions), FontConfig (typography), StyleConfig (behaviors), ParamConfig (parameters)
import UIKit
import TTBaseUIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions:
                     [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        // ── View Configuration (Colors) ──
        let view = ViewConfig()
        view.viewBgNavColor = UIColor.getColorFromHex(netHex: 0x4DA0DC)
        view.buttonBgDef = UIColor.getColorFromHex(netHex: 0x4DA0DC)
        view.buttonBgWar = UIColor.getColorFromHex(netHex: 0xC41F53)
        view.buttonBgDis = UIColor.gray.withAlphaComponent(0.4)
        view.viewBgColor = UIColor.white
        view.viewBgCellColor = UIColor.white
        view.lineDefColor = UIColor.getColorFromHex(netHex: 0xEDEDED)

        // ── Font Configuration ──
        let fontConfig = FontConfig()
        fontConfig.HEADER_SUPER_H = 24
        fontConfig.HEADER_H = 18
        fontConfig.TITLE_H = 14
        fontConfig.SUB_TITLE_H = 12
        fontConfig.SUB_SUB_TITLE_H = 10

        // ── Size Configuration ──
        let sizeConfig = SizeConfig()
        sizeConfig.H_BUTTON = 50.0
        sizeConfig.H_TEXTFIELD = 50.0
        sizeConfig.CORNER_RADIUS = 8.0
        sizeConfig.CORNER_BUTTON = 8.0

        // ── Style & Params ──
        let styleConfig = StyleConfig()
        styleConfig.dismissKeyboardType = .TEXT

        let paramsConfig = ParamConfig()
        paramsConfig.forceUpdateNewVersion = false

        // ── Apply Configuration ──
        TTBaseUIKitConfig.withDefaultConfig(
            withFontConfig: fontConfig,
            frameSize: sizeConfig,
            view: view,
            style: styleConfig,
            params: paramsConfig
        )?.start(withViewLog: true)

        // ── Window Setup ──
        self.window = UIWindow(frame: UIScreen.main.bounds)
        self.window!.rootViewController = UINavigationController(
            rootViewController: YourViewController()
        )
        self.window!.makeKeyAndVisible()

        return true
    }
}

🎨 ViewConfig Reference

Controls all colors across the framework:

PropertyTypeDescription
viewBgColorUIColorDefault background color for views
viewBgNavColorUIColorNavigation bar background color
viewBgLoadingColorUIColorLoading indicator color
viewBgCellColorUIColorTable/Collection cell background
buttonBgDefUIColorDefault button background
buttonBgWarUIColorWarning/danger button background
buttonBgDisUIColorDisabled button background
labelBgDefUIColorDefault label background
labelBgWarUIColorWarning label background
lineDefColorUIColorDefault separator line color
lineActiveColorUIColorActive/focused line color
textWarringColorUIColorWarning text color

📐 SizeConfig Reference

PropertyTypeDefaultDescription
H_BUTTONCGFloat50Default button height
W_BUTTONCGFloat147Default button width
H_TEXTFIELDCGFloat50Default text field height
H_SEARCH_BARCGFloat46Search bar height
CORNER_RADIUSCGFloat8Default corner radius
CORNER_BUTTONCGFloat8Button corner radius
H_SMALL_ICONCGFloat26Small icon size
H_SEGCGFloat50Segmented control height

🔤 FontConfig Reference

PropertyDefault (≤5.8")Default (>5.8")Description
HEADER_SUPER_H2424Super header font size
HEADER_H1818Header font size
TITLE_H1416Title font size
SUB_TITLE_H1214Subtitle font size
SUB_SUB_TITLE_H1012Small text font size

🔧 UI Debug Kit

TTBaseUIKit includes a powerful built-in debug tool to help visualize layouts and test views:

LogViewHelper.share.config(
    withDes: "Description for Developers",
    isStartAppToShow: false,
    passCode: ""
).onShow()
Pro Tip: Set a passCode to secure the debug section. Use .onShow() to activate on any screen — just long-press to open!

Debug features include:

  • SHOW LOG API RESPONSE — View all request/response data for API debugging
  • DEBUG UI LAYOUT — Triple-tap any screen to inspect layout boundaries
  • CAPTURE THE SCREEN — Capture and annotate screenshots
  • SETTING DEV — Add custom dev settings (e.g., environment switching)
TTBaseUIKit Debug Kit Demo

🚀 Next Steps