Swiftpack.co - xattacker/Polygon_iOS_API as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by xattacker.
xattacker/Polygon_iOS_API 1.0.2
an iOS swift Polygon UI View component
⭐️ 6
🕓 37 weeks ago
.package(url: "https://github.com/xattacker/Polygon_iOS_API.git", from: "1.0.2")


an iOS swift Polygon UI View component

Development Target: iOS 9

Android version API: https://github.com/xattacker/Polygon_Android_API

present a custom defined polygon view:
screen cut

The API could load data from code for json file(json parsing by ObjectMapper https://github.com/Hearst-DD/ObjectMapper)
and supports event callback



PolygonAPI can be added to your project using CocoaPods 0.36 or later by adding the following line to your Podfile:

pod 'ObjectMapper'
pod 'PolygonAPI'

Swift Package Manager

To add PolygonAPI to a Swift Package Manager based project, add:

.package(url: "https://github.com/xattacker/Polygon_iOS_API.git", .upToNextMajor(from: "1.0.2")),
.package(url: "https://github.com/tristanhimmelman/ObjectMapper.git", .upToNextMajor(from: "4.1.0")),

to your Package.swift files dependencies array.

How to use:

import PolygonAPI

var polygonView: UIPolygonView!

// load region map from json 
if let path = Bundle.main.path(forResource: "region", ofType: "json")
        // load map resource from json file
        let json = try String(contentsOfFile: path)

        if !json.isEmpty,
            let map = PolygonMap(JSONString: json)

// you could also add map region by code:
let region = PolygonRegion()
region.regionColor = UIColor.brown
region.regionId = "north"
region.titleInfo.title = "北部"
region.addPoint(CGPoint(x: 167, y: 103))
region.addPoint(CGPoint(x: 194, y: 142))
region.addPoint(CGPoint(x: 251, y: 170))
region.addPoint(CGPoint(x: 306, y: 173))
region.addPoint(CGPoint(x: 322, y: 162))
region.addPoint(CGPoint(x: 314, y: 81))
region.addPoint(CGPoint(x: 338, y: 56))
region.addPoint(CGPoint(x: 330, y: 32))
region.addPoint(CGPoint(x: 291, y: 19))
region.addPoint(CGPoint(x: 269, y: 2))
region.addPoint(CGPoint(x: 254, y: 30))
region.addPoint(CGPoint(x: 192, y: 49))

// the API provides delegate to catch some events
extension ViewController: UIPolygonViewDelegate
    func onRegionClicked(region: PolygonRegion)
        // click region area event callback
    func onRegionMarkClicked(mark: RegionMark, region: PolygonRegion)
        // click mark event callback


Stars: 6
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

supported for SPM
1 year ago

update Package.swift

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics