ランキングに戻る

cruisediary/Pastel

Swift

🎨 Gradient animation effect like Instagram

swiftinstagramgradientanimationpastel
スター成長
スター
3.5k
フォーク
186
週間成長
Issue
16
2k2.5k3k3.5k
2017年5月2020年5月2023年6月2026年7月
README

Pastel

🎨 Gradient animation effect like Instagram

Swift Version License Platform SPM compatible

pastel_01.gif pastel_02.gif pastel_03.gif

Requirements

  • iOS 16.0+
  • Swift 5.9+
  • Xcode 15+

Installation

Swift Package Manager

Add Pastel to your Package.swift:

dependencies: [
    .package(url: "https://github.com/cruisediary/Pastel.git", from: "1.0.0")
]

Or in Xcode: File → Add Package Dependencies and enter the repository URL.

CocoaPods

pod 'Pastel', '~> 1.0.0'

Usage

SwiftUI

Animated gradient background (preset)

import SwiftUI
import Pastel

struct ContentView: View {
    var body: some View {
        Text("Hello")
            .pastelBackground(.instagram)
    }
}

Animated gradient background (custom colors)

Text("Hello")
    .pastelBackground(colors: [
        UIColor(red: 156/255, green: 39/255, blue: 176/255, alpha: 1),
        UIColor(red: 255/255, green: 64/255, blue: 129/255, alpha: 1),
        UIColor(red: 32/255, green: 76/255, blue: 255/255, alpha: 1)
    ], duration: 3.0)

Animated gradient view

PastelGradientView(gradient: .sunset, duration: 4.0)
    .ignoresSafeArea()

Animated gradient text

PastelText("Pastel", font: .largeTitle, gradient: .instagram)

Shared state (coordinate multiple views)

let state = PastelAnimationState(
    colors: [.purple, .pink, .blue],
    duration: 3.0,
    timingCurve: .easeInOut,
    repeatBehavior: .count(5),
    autoreverses: true
)

PastelGradientView(state: state)
PastelText("Hello", state: state)

UIKit

Basic usage

override func viewDidLoad() {
    super.viewDidLoad()

    let pastelView = PastelView(frame: view.bounds)

    // Direction
    pastelView.startPastelPoint = .bottomLeft
    pastelView.endPastelPoint = .topRight

    // Duration
    pastelView.animationDuration = 3.0

    // Colors
    pastelView.setColors([
        UIColor(red: 156/255, green: 39/255, blue: 176/255, alpha: 1),
        UIColor(red: 255/255, green: 64/255, blue: 129/255, alpha: 1),
        UIColor(red: 123/255, green: 31/255, blue: 162/255, alpha: 1),
        UIColor(red: 32/255, green: 76/255, blue: 255/255, alpha: 1),
        UIColor(red: 58/255, green: 255/255, blue: 217/255, alpha: 1)
    ])

    pastelView.startAnimation()
    view.insertSubview(pastelView, at: 0)
}

Shared state with UIKit

let state = PastelAnimationState(
    colors: [.purple, .pink, .blue],
    duration: 3.0,
    timingCurve: .easeInOut
)

let pastelView = PastelView(frame: view.bounds)
pastelView.animationState = state
pastelView.startAnimation()
view.insertSubview(pastelView, at: 0)

🎨 Gradient Presets

30 built-in presets available via PastelGradient.

Designed by Alexander Zaytsev — https://dribbble.com/anwaltzzz

Gradient.png

Example Project

Clone the repo and open Example/Pastel.xcodeproj. No additional setup needed — Pastel is linked via SPM automatically.

Author

cruz, cruzdiary@gmail.com

Thanks

Many thanks to the contributors of this project.

License

Pastel is available under the MIT license. See the LICENSE file for more info.

関連リポジトリ
justjavac/free-programming-books-zh_CN

:books: 免费的计算机编程类中文书籍,欢迎投稿

GNU General Public License v3.0pythonjavascript
weibo.com/justjavac
117.7k28.2k
appwrite/appwrite

Appwrite® - complete cloud infrastructure for your web, mobile and AI apps. Including Auth, Databases, Storage, Functions, Messaging, Hosting, Realtime and more

TypeScriptnpmBSD 3-Clause "New" or "Revised" Licenseappwritedocker
appwrite.io
56.6k5.6k
dkhamsing/open-source-ios-apps

:iphone: Collaborative List of Open-Source iOS Apps

Creative Commons Zero v1.0 Universaliosswift
51.3k6k
serhii-londar/open-source-mac-os-apps

🚀 Awesome list of open source applications for macOS. https://t.me/s/opensourcemacosapps

Creative Commons Zero v1.0 Universalmacosmac
49.7k2.6k
iina/iina

The modern video player for macOS.

SwiftGNU General Public License v3.0macosvideo-player
iina.io
45.7k2.9k
Alamofire/Alamofire

Elegant HTTP Networking in Swift

SwiftMIT Licensenetworkingurlsession
42.4k7.7k
xitu/gold-miner

🥇掘金翻译计划,可能是世界最大最好的英译中技术社区,最懂读者和译者的翻译平台:

androidtranslation
juejin.cn/tag/%E6%8E%98%E9%87%91%E7%BF%BB%E8%AF%91%E8%AE%A1%E5%88%92
34.3k5k
MonitorControl/MonitorControl

🖥 Control your display's brightness & volume on your Mac as if it was a native Apple Display. Use Apple Keyboard keys or custom shortcuts. Shows the native macOS OSDs.

SwiftMIT Licensemacoskeyboard
monitorcontrol.app
33.8k983
shadowsocks/ShadowsocksX-NG

Next Generation of ShadowsocksX

SwiftGNU General Public License v3.0shadowsocksswift
32.9k7.8k
kodecocodes/swift-algorithm-club

Algorithms and data structures in Swift, with explanations!

SwiftMIT Licenseswiftdata-structures
29.1k5k
jordanbaird/Ice

Powerful menu bar manager for macOS

SwiftGNU General Public License v3.0macosmenubar
icemenubar.app
29k824
airbnb/lottie-ios

An iOS library to natively render After Effects vector animations

SwiftApache License 2.0animationbodymovin
lottie.airbnb.tech
26.8k3.8k