Latest 3.0.0
Homepage https://github.com/thefuntasty/Sonar
License MIT
Platforms ios 8.0, requires ARC
Authors

[![CI Status](http://img.shields.io/travis/Aleš Kocur/Sonar.svg?style=flat)](https://travis-ci.org/Aleš Kocur/Sonar)
Version
License
Platform

Sonar
Sonar

Simple radar style view, written in Swift, pure CoreAnimation (no images). Highly adjustable.

Usage

Just place the UIView somewhere in your controller and make it SonarView class.

SonarView copies the data source and delegate patter from UITableView.

/// Data source
public weak var dataSource: SonarViewDataSource?

/// SonarViewDelegate and SonarViewLayout
public weak var delegate: SonarViewDelegate?

There are three required methods.

public protocol SonarViewDataSource: class {
    func numberOfWaves(sonarView: SonarView) -> Int
    func sonarView(sonarView: SonarView, numberOfItemForWaveIndex waveIndex: Int) -> Int
    func sonarView(sonarView: SonarView, itemViewForWave waveIndex: Int, atIndex: Int) -> SonarItemView
}

SonarItemView is just a UIView subclass. In order to use your custom view in radar, make your view SonarItemView subclass. The size of view is determined via layout. The layout is defined by SonarViewLayout protocol. Sonar comes with one predefined layout – SonarViewCenteredLayout. The items in a wave are placed from edges to the center, for example if we have 4 items in wave, first is placed at the left side, second at the right side, third at the left again but a right from the first one and so on. I know, the image would be better:

Sonar

If you need different behaviour, you can of course create your own layout by adopting the SonarViewLayout a pass it to the SonarView. See SonarViewLayout for more information.

The last protocol is Delegate which handles selections and titles on each wave

public protocol SonarViewDelegate: class {
    func sonarView(sonarView: SonarView, didSelectObjectInWave waveIndex: Int, atIndex: Int)
    func sonarView(sonarView: SonarView, textForWaveAtIndex waveIndex: Int) -> String?
}

If distanceForWaveAtIndex returns nil, the label will be hidden. For more informations see the Example project.

Appearance

There are 3 colours that can be adjusted.

class public var lineColor: UIColor
class public var lineShadowColor: UIColor
class public var distanceTextColor: UIColor

Contribution

If you need to expose another properties or you have ideas how to improve it, file issue or send pull request, I’ll be happy to discuss it.

Requirements

iOS 8+, Swift 2.2+

Installation

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

pod "Sonar"

Author

Aleš Kocur, [email protected]

License

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

Latest podspec

{
    "name": "Sonar",
    "version": "3.0.0",
    "summary": "Radar style view written in swift",
    "description": "Simple radar style view written in swift",
    "homepage": "https://github.com/thefuntasty/Sonar",
    "license": "MIT",
    "authors": {
        "Aleu0161 Kocur": "[email protected]"
    },
    "source": {
        "git": "https://github.com/thefuntasty/Sonar.git",
        "tag": "3.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This