Latest 0.1.1
Homepage https://github.com/kanumuri9593/YVLegendView
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

A simple Legend View to categorize and group layers in the map into sections.

Build using Simple callback Api’s and custom nib’s easy to understand and customize to your requirements.

YVLegendView
YVLegendView
YVLegendView

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Using CocoaPods

Add pod 'YVLegendView' to your Podfile and run pod install. Also add use_frameworks! to the Podfile.

use_frameworks!
pod 'YVLegendView'

Manual

Just Clone or download this repo to your desktop
drag and drop YVLegendView Folder to your Project, that’s it you are ready to use it in your view.

Support

Written in Swift 3
supports from iOS 9 and above
Xcode 8 and above

Usage

import YVLegendView to your ViewController

then follow these three steps:

First simply Initiate a array of Objects (Layer info with icons)

LegendObject is an object which expects a title to display as section header title and a array of layers categorized under it of type infoObject which takes a img and name as parameters

let MultipleLegendFeed:[LegendObject] = [
LegendObject(name: "Traffic Camera", info: [
infoObject(img: UIImage(named: "map_camera_on"), title: "Camera - On"),
infoObject(img:UIImage(named: "map_camera_off"), title: "Camera - On")
]),
LegendObject(name: "Roadway Weather", info: [
infoObject(img: UIImage(named: "icon_weather_dry"), title: "Dry"),
infoObject(img: UIImage(named: "icon_weather_wet"), title: "Wet"),
infoObject(img: UIImage(named: "icon_weather_ice_watch"), title: "Ice Watch"),
infoObject(img: UIImage(named:"map_weather_sun"), title: "Sun"),
infoObject(img: UIImage(named: "icon_weather_unknown"), title: "Unkonwon")
]),
LegendObject(name: "Water Level", info: [
infoObject(img: UIImage(named: "flooding"), title: "Flooding Occuring"),
infoObject(img: UIImage(named: "flooding-nodata"), title: "No Dota Available")
])
]

Add the following method to your ViewController
The frame of the legend View is customizable according to your requirements including the animation you want the view to appear

internal func AddLegendView(LegendInfoFeed:[LegendObject]){
let  legendView = YVLegendView()
legendView.removeFromSuperview()
legendView.LegendFeed = LegendInfoFeed
legendView.frame = CGRect(x:UIScreen.main.bounds.width - 20.5 , y: 70, width: 219, height:300)
legendView.OpenLegend = { (legendView) in
UIView.animate(withDuration: 1.0, animations: {
legendView.frame = CGRect(x:UIScreen.main.bounds.width - 216 , y: 70, width: 219, height:300)
})
}
legendView.CloseLegend = { (legendView) in
UIView.animate(withDuration: 1.0, animations: {
legendView.frame = CGRect(x:UIScreen.main.bounds.width - 20.5 , y: 70, width: 219, height:300)
})
}
view.addSubview(legendView)
}

the call this method in ViewDidLoad

AddLegendView(LegendInfoFeed:MultipleLegendFeed)

It’s done you can reuse this View in multiple maps with custom layers and fell free to customize the files according to your need

Author

Yeswanth Varma Kanumurikanumuri9593

License

This project is licensed under the MIT License – see the LICENSE.md file for details

Latest podspec

{
    "name": "YVLegendView",
    "version": "0.1.1",
    "summary": "A simple Legend View which slides in to show categorize and group layers in the map into sections.",
    "description": "### InstallingnJust Clone or download this repo to your desktopndrag and drop **YVLegendView** Folder to your Project, thats it you are ready to use it in your view.nn### PrerequisitesnWritten in **Swift 3**nsupports from iOS 9 and abovenXcode 8 and abovenn## Getting StartednnFirst simply Initiate a array of Objects (Layer info with icons)nnLegendObject is an object which expects a title to display as section header title and a array of layers categorized under it of type infoObject which takes a img and name as parametersn```swiftnlet MultipleLegendFeed:[LegendObject] = [nLegendObject(name: "Traffic Camera", info: [ninfoObject(img: UIImage(named: "map_camera_on"), title: "Camera - On"),ninfoObject(img:UIImage(named: "map_camera_off"), title: "Camera - On")n]),nLegendObject(name: "Roadway Weather", info: [ninfoObject(img: UIImage(named: "icon_weather_dry"), title: "Dry"),ninfoObject(img: UIImage(named: "icon_weather_wet"), title: "Wet"),ninfoObject(img: UIImage(named: "icon_weather_ice_watch"), title: "Ice Watch"),ninfoObject(img: UIImage(named:"map_weather_sun"), title: "Sun"),ninfoObject(img: UIImage(named: "icon_weather_unknown"), title: "Unkonwon")n]),nLegendObject(name: "Water Level", info: [ninfoObject(img: UIImage(named: "flooding"), title: "Flooding Occuring"),ninfoObject(img: UIImage(named: "flooding-nodata"), title: "No Dota Available")n])n]n```nAdd the following method to your ViewControllernThe frame of the legend View is customizable according to your requirements including the animation you want the view to appearn```swiftninternal func AddLegendView(LegendInfoFeed:[LegendObject]){nlet  legendView = YVLegendView()nlegendView.removeFromSuperview()nlegendView.LegendFeed = LegendInfoFeednlegendView.frame = CGRect(x:UIScreen.main.bounds.width - 20.5 , y: 70, width: 219, height:300)nlegendView.OpenLegend = { (legendView) innUIView.animate(withDuration: 1.0, animations: {nlegendView.frame = CGRect(x:UIScreen.main.bounds.width - 216 , y: 70, width: 219, height:300)n})n}nlegendView.CloseLegend = { (legendView) innUIView.animate(withDuration: 1.0, animations: {nlegendView.frame = CGRect(x:UIScreen.main.bounds.width - 20.5 , y: 70, width: 219, height:300)n})n}nview.addSubview(legendView)n}n```nnthe call this method in ViewDidLoadnn```swiftnAddLegendView(LegendInfoFeed:MultipleLegendFeed)n```nThats it its done you can reuse this View in multiple maps with custom layers and fell free to customize the files according to your need",
    "homepage": "https://github.com/kanumuri9593/YVLegendView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Yeswanth Varma Kanumuri": "[email protected]"
    },
    "source": {
        "git": "https://github.com/kanumuri9593/YVLegendView.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "YVLegendView/Classes/**/*",
    "resource_bundles": {
        "YVLegendView": [
            "YVLegendView/**/*.{xib,png}"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This