Communitygithub.com

zinxj/uikit-expert-skill

使用 AI 代理技能提供準確、高效且現代的 UIKit Swift 程式碼,專注於最佳實踐與效能最佳化。

uikit-expert-skill 是什麼?

此技能專為協助開發者透過 AI 代理(如 Claude Code、Cursor 或 Codex)生成高品質的 UIKit 程式碼而設計。它模擬一位 UIKit 專家,強調遵循 Apple 官方建議的最佳實踐,如使用 Auto Layout、效能最佳化(例如 cell 重用、避免離屏渲染)以及現代 iOS 開發模式(包括 SwiftUI 與 UIKit 的整合)。支援多種開發平台,能根據使用者需求提供安全、可讀且高效的 Swift 程式碼片段,並附帶詳細註解。透過分析使用者輸入的上下文,技能可自動推薦合適的 UIKit 元件與最佳化策略,顯著提升開發效率與程式碼品質。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add zinxj/uikit-expert-skill

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

uikit-expert-skill 是做什麼的?

使用 AI 代理技能提供準確、高效且現代的 UIKit Swift 程式碼,專注於最佳實踐與效能最佳化。

功能

  • 產出遵循 Apple 官方 UIKit 最佳實踐的程式碼。
  • 自動套用效能最佳化技術,例如 cell 重用、避免離屏渲染與漸進式載入。
  • 支援 SwiftUI 與 UIKit 的無縫整合模式。
  • 根據使用者需求,推薦合適的 UIKit 元件與架構。
  • 提供詳細的中文註解,協助開發者理解程式碼邏輯。

使用方式

  1. 在支援 AI 代理的開發環境中安裝此技能(例如 Cursor 或 Codex)。
  2. 於對話中描述您的 UIKit 需求,例如:
    • 「建立一個可重用的自訂 UITableViewCell,支援動態高度與圖片快取。」
    • 「實作一個符合現代 iOS 標準的導航控制器動畫過渡效果。」
  3. AI 代理將產生對應的 Swift 程式碼,包含必要的 import 與最佳化建議。

支援平台

  • Claude Code
  • Cursor
  • Codex
  • 其他相容的 AI 代理工具

範例

自訂 UITableViewCell

import UIKit

class CustomTableViewCell: UITableViewCell {
    static let reuseIdentifier = "CustomTableViewCell"

    private let thumbnailImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.contentMode = .scaleAspectFill
        imageView.clipsToBounds = true
        imageView.translatesAutoresizingMaskIntoConstraints = false
        return imageView
    }()

    private let titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 16, weight: .medium)
        label.translatesAutoresizingMaskIntoConstraints = false
        return label
    }()

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupView()
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) 尚未實作")
    }

    private func setupView() {
        contentView.addSubview(thumbnailImageView)
        contentView.addSubview(titleLabel)

        NSLayoutConstraint.activate([
            thumbnailImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 16),
            thumbnailImageView.centerYAnchor.constraint(equalTo: contentView.centerYAnchor),
            thumbnailImageView.widthAnchor.constraint(equalToConstant: 50),
            thumbnailImageView.heightAnchor.constraint(equalToConstant: 50),

            titleLabel.leadingAnchor.constraint(equalTo: thumbnailImageView.trailingAnchor, constant: 12),
            titleLabel.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16),
            titleLabel.centerYAnchor.constraint(equalTo: contentView.centerYAnchor)
        ])
    }

    func configure(with title: String, image: UIImage?) {
        titleLabel.text = title
        thumbnailImageView.image = image
    }

    override func prepareForReuse() {
        super.prepareForReuse()
        thumbnailImageView.image = nil
        titleLabel.text = nil
    }
}

注意事項

  • 本技能專注於 UIKit,不涵蓋 SwiftUI 的獨立功能。
  • 建議搭配 Xcode 的 Interface Builder 或程式碼設定以達到最佳效果。
  • 對於進階效能問題,請參閱 Apple 官方文件。

授權條款

本技能以 MIT 授權條款釋出。詳情請見 LICENSE 檔案。

相關技能