Latest 0.0.1
Homepage https://github.com/3ph/RxJoystickView
License MIT
Platforms ios 8.0
Dependencies RxCocoa
Authors

CI Status
Version
License
Platform
Swift

A simple reactive joystick view widget. Tracks horizontal and vertical position of dragged thumb from center in range [-1.0, 1.0]. Both axes can be individually disabled.

Screenshot

Usage

Simply add as custom view to storyboard or create programatically.

let joystickView = RxJoystickView()

Generic properties:

/// Flag determining if vertical line should be drawn.
/// Settings this to false also means vertical movement will be disabled.
joystickView.showVerticalLine = true

/// Flag determining if horizontal line should be drawn.
/// Settings this to false also means horizontal movement will be disabled.
joystickView.showHorizontalLine = true

/// Vertical line color
joystickView.verticalLineColor = UIColor.gray

/// Horizontal line color
joystickView.horizontalLineColor = UIColor.gray

/// Joystick thumb radius in pt
joystickView.thumbRadius = 10

/// Joystick thumb color
joystickView.thumbColor = UIColor.lightGray

Observing changes

// Horizontal thumb position changed: -1 is leftmost position, +1 is rightmost position.
joystickView
    .rx
    .horizontalPositionChanged
    .asDriver(onErrorJustReturn: 0)
    .drive(onNext: { position in
        NSLog("Horizontal position: (position)")
    }).disposed(by: disposeBag)

// Vertical thumb position changed: -1 is topmost position, +1 is bottommost position.
joystickView
    .rx
    .verticalPositionChanged
    .asDriver(onErrorJustReturn: 0)
    .drive(onNext: { position in
        NSLog("Vertical position: (position)")
    }).disposed(by: disposeBag)

Example

To run the example project, run pod try.

Requirements

iOS 8+, RxSwift.

Installation

RxJoystickView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'RxJoystickView'

Author

Tomas Friml, [email protected]

License

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

Latest podspec

{
    "name": "RxJoystickView",
    "version": "0.0.1",
    "summary": "A simple reactive joystick view widget.",
    "description": "Tracks horizontal and vertical position of dragged thumb from center in range [-1.0, 1.0]. Both axes can be individually disabled.",
    "homepage": "https://github.com/3ph/RxJoystickView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "3ph": "[email protected]"
    },
    "source": {
        "git": "https://github.com/3ph/RxJoystickView.git",
        "tag": "0.0.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "RxJoystickView/Classes/**/*",
    "dependencies": {
        "RxCocoa": [
            "~> 4.1.2"
        ]
    }
}

Pin It on Pinterest

Share This