The JoyStick UI library for SwiftUI
OMJoystick
This is the JoyStick UI library for SwiftUI.
Examples
Swift
Simple
import SwiftUI
import OMJoystick
struct ContentView: View {
var body: some View {
OMJoystick(colorSetting: ColorSetting()) { (joyStickState, stickPosition) in
}
}
}
Customize
import SwiftUI
import OMJoystick
import SFSafeSymbols
struct ContentView: View {
let iconSetting = IconSetting(
leftIcon: Image(systemSymbol: .arrowLeft),
rightIcon: Image(systemSymbol: .arrowRight),
upIcon: Image(systemSymbol:.arrowUp),
downIcon: Image(systemSymbol: .arrowDown)
)
let colorSetting = ColorSetting(subRingColor: .red, bigRingNormalBackgroundColor: .green, bigRingDarkBackgroundColor: .blue, bigRingStrokeColor: .yellow)
var body: some View {
GeometryReader { geometry in
VStack(alignment: .center, spacing: 5) {
OMJoystick(isDebug: true, iconSetting: self.iconSetting, colorSetting: ColorSetting(), smallRingRadius: 70, bigRingRadius: 120
) { (joyStickState, stickPosition) in
}.frame(width: geometry.size.width-40, height: geometry.size.width-40)
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Installation (CocoaPods)
pod 'OMJoystick'