Bring the polar coordinate system into your iOS project!
As you know, UIView uses Cartesian Coordinate System. PolarKit is a project that brings Polar Coordinate System into the iOS world!
With the PolarKit, you can place your view with angle & radius.
The goal of PolarKit is to provide UI components that has benefits when presented with the polar coordinate system.
PolarKit currently provides following components.
CircularScrollView
: Polar coordinated version ofUIScrollView
RotatableView
: Simple rotatable view
import PolarKit
...
let circular = CircularScrollView(frame: frame)
// PolarCoordinatedView is just a subclass of UIView
let subview = PolarCoordinatedView(radius: 100, angle: Double.pi, frame: anotherFrame)
// Wrap your view with PolarCoordinatedView
subview.addSubview(yourView)
circular.addSubview(subview)
circular.contentLength = 2 * Double.pi
Once you remind UIScrollView, you can find out it has similar look-and-feel.
let scrollView = UIScrollView(frame: frame)
let subview = UIView(frame: anotherFrame)
scrollView.addSubview(subview)
scrollView.contentSize = CGSizeMake(width, height)
import PolarKit
...
let rotatable = RotatableView(frame: frame)
rotatable.addSubview(yourViewToRotate)
// Setting the offset
rotatable.offset = Double.pi
// Adding an animation
// Unfortunately, `UIView.animateWithDuration()` is not supported
let anim = CABasicAnimation(keyPath: "offset")
anim.toValue = 2 * Double.pi
rotatable.layer.addAnimation(anim, forKey: "your-key")
- Swift 2.2
To run the example project,
- Clone the repo
- Run
pod install
from the Example directory - Open
Example/PolarKit.xcworkspace
- Run the target named
PolarKit-Example
PolarKit is going to available through CocoaPods soon. To install it, simply add the following line to your Podfile:
pod "PolarKit"
Jeong Yong-uk, [email protected]
PolarKit is available under the MIT license. See the LICENSE file for more info.