Latest 0.1.0
Homepage https://github.com/blurryssky/BSNumbers
License MIT
Platforms ios 7.0
Authors

Overview

if the view did not add constraints, you need to rotate the view manually when screen’s orientation changed.

BSNumbersGIF.gif

Installation

pod ‘BSNumbers’, ‘~> 0.1.0’

Usage

Supple an array with models as datasource

NSArray<NSDictionary *> *flightsInfo = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"flightsInfo" ofType:@"plist"]];
NSMutableArray<Flight *> *flights = @[].mutableCopy;
for (NSDictionary *flightInfo in flightsInfo) {
    Flight *flight = [[Flight alloc]initWithDictionary:flightInfo];
    [flights addObject:flight];
}

This is the model: Flight

@interface Flight : NSObject

@property (strong, nonatomic) NSString *company;
@property (strong, nonatomic) NSString *number;
@property (strong, nonatomic) NSString *typeOfAircraft;
@property (strong, nonatomic) NSString *date;
@property (strong, nonatomic) NSString *placeOfDeparture;
@property (strong, nonatomic) NSString *placeOfDestination;
@property (strong, nonatomic) NSString *departureTime;
@property (strong, nonatomic) NSString *arriveTime;
@property (strong, nonatomic) NSString *price;

- (instancetype)initWithDictionary:(NSDictionary *)dic;

@end

Set the datasource and the other optional attribute

self.numbersView.bodyData = flights;
optional attribute
self.numbersView.headerData = @[@"Flight Company", @"Flight Number", @"Type Of Aircraft", @"Date", @"Place Of Departure", @"Place Of Destination", @"Departure Time", @"Arrive Time", @"Price"];
self.numbersView.freezeColumn = 1;
self.numbersView.bodyFont = [UIFont systemFontOfSize:14];

Display

[self.numbersView reloadData];

Use delegate

#pragma mark -- BSNumbersViewDelegate

- (UIView *)numbersView:(BSNumbersView *)numbersView viewForBodyFreezeInColumn:(NSInteger)column text:(NSString *)text {
    CGSize size = [numbersView sizeForFreezeColumn:column];

    UIView *view = [UIView new];
    view.backgroundColor = [UIColor lightGrayColor];

    UIView *square = [UIView new];
    square.backgroundColor = [UIColor orangeColor];
    square.frame = CGRectMake(0, 0, 15, 15);
    square.center = CGPointMake(size.width/2 - 35, size.height/2);
    [view addSubview:square];

    UILabel *label = [UILabel new];
    label.text = text;
    label.textColor = [UIColor whiteColor];
    label.font = [UIFont systemFontOfSize:14];
    label.frame = CGRectMake(0, 0, 100, 100);
    label.center = CGPointMake(size.width/2 + 10, size.height/2);
    label.textAlignment = NSTextAlignmentCenter;
    [view addSubview:label];

    return view;
}

Latest podspec

{
    "name": "BSNumbers",
    "version": "0.1.0",
    "summary": "A view that display form just like numbers",
    "description": "u7528u4e8eu5b9eu73b0u7c7bu4f3cmacu7684numbersuff08windowsu7684exceluff09u529fu80fdu7684u8868u683cu89c6u56feuff0cu5177u5907u7684u7279u6027u5305u62ecu51bbu7ed3u5217u3001u81eau52a8u8ba1u7b97u5bbdu5ea6u4ee5u53cau5febu901fu8bbeu7f6eu6570u636eu6e90",
    "homepage": "https://github.com/blurryssky/BSNumbers",
    "license": "MIT",
    "authors": {
        "blurryssky": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/blurryssky/BSNumbers.git",
        "tag": "0.1.0"
    },
    "source_files": [
        "BSNumbers",
        "BSNumbersSample/BSNumbers/*"
    ],
    "exclude_files": "Classes/Exclude"
}

Pin It on Pinterest

Share This