WWFortuneWheelView - A scroll wheel that can be customized.

Overview

WWFortuneWheelView

Swift-5.5 iOS-13.0 Swift Package Manager-SUCCESS LICENSE

A scroll wheel that can be customized. 一個可以自訂數量的滾輪.

Installation with Swift Package Manager

dependencies: [
    .package(url: "https://github.com/William-Weng/WWFortuneWheelView.git", .upToNextMajor(from: "1.0.0"))
]

Example

import UIKit
import WWFortuneWheelView

final class ViewController: UIViewController {
    
    @IBOutlet weak var myFortuneWheelView: WWFortuneWheelView!
    @IBOutlet weak var indexLabel: UILabel!
    @IBOutlet weak var angleLabel: UILabel!
    
    private let decimalCount: UInt = 3
    
    private var index = 0
    private var angle: (unit: CGFloat, start: CGFloat, end: CGFloat) = (0, 0, 0)
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        initSetting()
    }
    
    @objc func didPressed(_ sender: UIButton) { indexLabel.text = "\(sender.tag)" }
}

// MARK: - WWFortuneWheelViewDelegate
extension ViewController: WWFortuneWheelViewDelegate {
    
    func willRotate(_ wheelView: WWFortuneWheelView, unitAngle: CGFloat, startAngle: CGFloat) {
        angle.unit = unitAngle
        angle.start = startAngle
        angleLabel.text = "\(startAngle._decimalPoint(decimalCount))"
    }
    
    func rotating(_ wheelView: WWFortuneWheelView, from startIndex: Int, to endIndex: Int, angle: CGFloat) {
        indexLabel.text = "\(startIndex) to \(endIndex)"
        angleLabel.text = "\(angle._decimalPoint(decimalCount))"
    }
    
    func autoRotated(_ wheelView: WWFortuneWheelView, from startIndex: Int, to endIndex: Int, duration: TimeInterval) {
        indexLabel.text = "\(startIndex) to \(endIndex)"
    }
    
    func didRotated(_ wheelView: WWFortuneWheelView, at index: Int, angle: CGFloat) {
        
        indexLabel.text = "\(index)"
        angleLabel.text = "\(angle._decimalPoint(decimalCount))"

        self.angle.end = angle
        _ = wheelView.bullseyeButtons._isSelected(only: index)
    }
}

// MARK: - 小工具
private extension ViewController {
    
    /// 初始的設定
    func initSetting() {
        
        myFortuneWheelView.myDelegate = self
        myFortuneWheelView.rotateRange = 120...180
        myFortuneWheelView.bullseyeButtons.forEach { button in
            
            let stateImages: [(image: UIImage, state: UIControl.State)] = [
                (image: #imageLiteral(resourceName: "LightOff"), state: .normal),
                (image: #imageLiteral(resourceName: "LightHighlight"), state: .selected),
                (image: #imageLiteral(resourceName: "LightOn"), state: .highlighted),
            ]

            stateImages.forEach { (image, state) in
                button.setImage(image, for: state)
            }
            
            button.setTitle(nil, for: .normal)
            button.addTarget(self, action: #selector(didPressed(_:)), for: .touchUpInside)
        }
    }
}
You might also like...
Pop-up based view(e.g. alert sheet), can be easily customized.
Pop-up based view(e.g. alert sheet), can be easily customized.

MMPopupView 中文介绍 A basic Pop-Up Kit allows you to easily create Pop-Up view. You can focus on the only view you want to show. Besides, it comes with 2

JDSwiftMap is an IOS Native MapKit Library.  You can easily make a highly customized HeatMap.
JDSwiftMap is an IOS Native MapKit Library. You can easily make a highly customized HeatMap.

JDSwiftMap is an IOS Native MapKit Library. You can easily make a highly customized HeatMap. Installation Cocoapods pod 'JDSWiftHeatMap' Usage JDSwi

PTPopupWebView is a simple and useful WebView for iOS, which can be popup and has many of the customized item.
PTPopupWebView is a simple and useful WebView for iOS, which can be popup and has many of the customized item.

PTPopupWebView PTPopupWebView is a simple and useful WebView for iOS, which can be popup and has many of the customized item. Requirement iOS 8.0 Inst

An instagram-like image editor that can apply preset filters passed to it and customized editings to a binded image.
An instagram-like image editor that can apply preset filters passed to it and customized editings to a binded image.

CZImageEditor CZImageEditor is an instagram-like image editor with clean and intuitive UI. It is pure swift and can apply preset filters and customize

Library that holds multiple books loaded from json in a scroll view where each book can be tapped on, favorited, rated, and opened to read
Library that holds multiple books loaded from json in a scroll view where each book can be tapped on, favorited, rated, and opened to read

Library that holds multiple books loaded from json in a scroll view where each book can be tapped on, favorited, rated, and opened to read. If a book is a favorite, an orange star appears on the book's cover. Page number, favorites, and ratings are saved for each session of the app.

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.
Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS
NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS

NextLevel is a Swift camera system designed for easy integration, customized media capture, and image streaming in iOS. Integration can optionally leverage AVFoundation or ARKit.

A lightweight customized tabbar view. 📌
A lightweight customized tabbar view. 📌

A lightweight customized tabbar view. Screenshots Features Installation Setup ToDos Credits Thanks License Screenshots Features Easily Configurable an

PrettyBorder is a SwiftUI package for managing an customized border and background at any kind of view.
PrettyBorder is a SwiftUI package for managing an customized border and background at any kind of view.

PrettyBorder Description PrettyBorder is a SwiftUI package for managing an customized border and background at any kind of view. Preview of end result

[iOS] Add customized buttons and toolbars to your UITextInputs.
[iOS] Add customized buttons and toolbars to your UITextInputs.

RFKeyboardToolbar This is a flexible UIView and UIButton subclass to add customized buttons and toolbars to your UITextFields/UITextViews. This projec

SwiftyKeyboard: a full customized numeric keyboard for iOS
SwiftyKeyboard: a full customized numeric keyboard for iOS

SwiftyKeyboard Overview SwiftyKeyboard is an iOS customized enhanced keyboard. T

Customized MenuBar for tvOS
Customized MenuBar for tvOS

#PLMenuBar PLMenuBar is a customized menubar for tvOS, simple and easy to use. ####Preview ####Requirement XCode 7.3 ####Support Support desc detail v

A collection of common tools and commands used throughout the development process, customized for Kipple projects.

KippleTools A collection of common tools and commands used throughout the development process, customized for Kipple projects. ⚠️ The code in this lib

Gemini is rich scroll based animation framework for iOS, written in Swift.
Gemini is rich scroll based animation framework for iOS, written in Swift.

Overview What is the Gemini? Gemini is rich scroll based animation framework for iOS, written in Swift. You can easily use GeminiCollectionView, which

A horizontal scroll dial like Instagram.
A horizontal scroll dial like Instagram.

HorizontalDial Preview Requirements iOS 8.0+ Swift 5 Storyboard support Installation CocoaPods use_frameworks! pod "HorizontalDial" Manually To instal

Medium's upper and lower Menu in Scroll.
Medium's upper and lower Menu in Scroll.

Notice: MediumScrollFullScreen is no longer being maintained/updated. MediumScrollFullScreen Medium's upper and lower menu in Scroll. Demo Description

A paging menu controller built from other view controllers placed inside a scroll view (like Spotify, Windows Phone, Instagram)
A paging menu controller built from other view controllers placed inside a scroll view (like Spotify, Windows Phone, Instagram)

Unfortunately, life gets in the way sometimes and I won't be able to maintain this library any longer and upgrade this library to where it needs to be

A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

Owner
William-Weng
William-Weng
A fully customizable container view controller to display a set of ViewControllers in a horizontal scroll view. Written in Swift.

DTPagerController This is a control for iOS written in Swift. DTPagerController is simple to use and easy to customize. Screenshots Default segmented

Tung Vo 290 Nov 13, 2022
You can easily add awesome animated context menu to your app.

Context-Menu.iOS You can easily add awesome animated context menu to your app. Made in Check this [project on dribbble] (https://dribbble.com/shots/17

Yalantis 1.8k Nov 17, 2022
A menu which can ... BOOM! - iOS

VHBoomMenuButton 2.0.0 Comes Finally After the version 2.0.0 has been published on Android platform, I started developing the new version for BMB on i

黄伟平 577 Nov 14, 2022
Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. 🌶

RHSideButtons ?? Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app

Robert Herdzik 166 Nov 14, 2022
This app can translate the MainMenu.xib automatically

Main Menu Translator This app can translate the MainMenu.xib automatically. Desc

Megabits_mzq 17 May 28, 2022
A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI.

Scaling Header Scroll View A scroll view with a sticky header which shrinks as you scroll. Written with SwiftUI. We are a development agency building

Exyte 395 Dec 31, 2022
Fortune spinning wheel library built using SwiftUI, supports dynamic content.

Fortune Wheel Fortune spinning wheel ?? library built using SwiftUI, supports dynamic content. Preview - Spin Wheel ⚙️ CocoaPods Installation FortuneW

Sameer Nawaz 51 Dec 23, 2022
The ultimate spinning wheel view that supports dynamic content and rich customization.

The ultimate spinning wheel control that supports dynamic content and rich customization. Main Features ?? Dynamic content, supports texts, images, an

Sherzod Khashimov 250 Dec 27, 2022
SMNumberWheel is a subclass of UIControl written in Swift, which is ideal for picking numbers using a rotating wheel.

SMNumberWheel version: 1.0.3 [![CI Status](http://img.shields.io/travis/Sina Moetakef/SMNumberWheel.svg?style=flat)](https://travis-ci.org/Sina Moetak

null 26 Mar 15, 2022
ColorWheel Test - An attempt at creating a Color Wheel to be utilized for color picking in SwiftUI utlizing various tutuorials on youtube

This code focuses on creating a Color Wheel in which a user will be able to select a desired color to then be implemented in another project that will display that color in an LED connected to an arduino

Gerardo Cerpa 0 Jan 15, 2022