Skip to content

gspd-mobi/SegmentedBarView-iOS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GSPDSegmentedBarView

Version License Platform

Screenshots

Imgur Imgur

Usage

Constructor and setters

GSPDSegmentedBarView *segmentedBarView = [[GSPDSegmentedBarView alloc] init];
segmentedBarView.unit = attributedUnit;
segmentedBarView.segments = segmentedBarViewSegments;
segmentedBarView.value = value;
GSPDSegmentedBarView *segmentedBarView = [[GSPDSegmentedBarView alloc] initWithValue:@(1.0) unit:nil segments:segments];

Also you can use it with xibs and storyboards.

Create segments

In any case you should create segments list to put in view.

GSPDSegmentedBarSegment *segment1 = [[GSPDSegmentedBarSegment alloc] initWithMinValue:@(0.1) maxValue:@(1) color:[UIColor colorWithRed:0.94 green:0.24 blue:0.18 alpha:1]];
    segment1.segmentDescription = @"Segment 1";
    segment1.sideTextStyle = GSPDSegmentedBarSegmentSideTextStyleOneSided;
    GSPDSegmentedBarSegment *segment2 = [[GSPDSegmentedBarSegment alloc] initWithMinValue:@(1.1) maxValue:@(2.1) color:[UIColor colorWithRed:0.55 green:0.78 blue:0.24 alpha:1]];
    segment2.segmentDescription = @"Segment 2";
    GSPDSegmentedBarSegment *segment3 = [[GSPDSegmentedBarSegment alloc] initWithMinValue:@(2.1) maxValue:@(3.1) color:[UIColor colorWithRed:0.94 green:0.24 blue:0.18 alpha:1]];
    segment3.segmentDescription = @"Segment 3";
    segment3.sideTextStyle = GSPDSegmentedBarSegmentSideTextStyleOneSided;
    
segmentedBarView.segments = @[segment1, segment2, segment3];

Each segment contains min and max value, color, description text (optional), custom text (optional). Value sign position is calculated automatically in these intervals.

Also there can be segments with no min and max. Then you should set valueSegmentIndex field of SegmentedBarView, it's just an index of segment to show value sign over.

Installation

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

pod "GSPDSegmentedBarView"

Author

Alexander Kiyaykin, GSPD, company@gspd.mobi

License

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


This code was produced for Clinishare Ltd. This code is published as open-source with the permission of Clinishare Ltd. www.clinishare.net

About

Custom UI control for android which is showing data as a segments and a value inside them.

Resources

License

Stars

Watchers

Forks

Packages

No packages published