Latest 1.0.1
Homepage https://github.com/Samueler/SCSegment
License MIT
Platforms ios 8.0
Dependencies SDWebImage
Authors

SCSegment supports setting up tabs with pictures using web pictures and local pictures.

Features

  • Supports multiple style,including style of text, image and both text and image.
  • Supports display net images with ‘URL’.
  • Supports advanced title styling with text attributes for font and color.
  • Support horizontal scrolling and scroll to center.
  • Supports blocks to observe index changed.
  • Works with ARC and iOS >= 8.

Installation

CocoaPods

The easiest way of installing SCSegment is via CocoaPods.

pod 'SCSegment'

Old-fashioned way

  • Add Core file to your project.
  • #import "SCSegment.h" where you want to add the control.

Usage

You can create ‘SCSegment’ instance by instance functions and class functions.

NSArray *titles = @[@"One", @"Two", @"Three", @"Four", @"Five",@"Six", @"Seven", @"Eight", @"Nine", @"Ten"];
NSString *urlString = @"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1529668872575&di=c1f145e6c728b8bb145e8d2a10193155&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F0196a156c937e46ac7252ce68a8504.png";
NSArray *images = @[@"sc_normal", @"sc_normal", @"sc_normal", @"sc_normal", @"sc_normal", @"sc_normal", @"sc_normal", @"sc_normal", @"sc_normal", @"sc_normal"];
NSArray *selectedImages = @[@"urlString", @"sc_selected", @"sc_selected", @"sc_selected", @"sc_selected", @"sc_selected", @"sc_selected", @"urlString", @"sc_selected", @"sc_selected"];
SCSegment *textSegment = [[SCSegment alloc] initWithTitles:titles]; 
SCSegment *imageSegment = [[SCSegment alloc] initWithImages:images selectedImages:selectedImages];
SCSegment *textImageSegment = [[SCSegment alloc] initWithImages:images selectedImages:selectedImages titles:titles];

or

SCSegment *textSegment = [SCSegment segmentWithTitles:titles]; 
SCSegment *imageSegment = [SCSegment segmentWithImages:images selectedImages:selectedImages];
SCSegment *textImageSegment = [SCSegment segmentWithImages:images selectedImages:selectedImages titles:titles];

You can observe index by block like this:

segment.indexChangeBlock = ^(NSInteger index) {
    NSLog(@"to do something");
};

You can also set segment properties to change seagment appearence.If you want to know all usages,please check the ‘viewController.m’ file in the project.

Attention

  1. Don’t create instance with system init functions,because SCSegment forbids those functions.
  2. Please make sure of the number of the images and the number of the selected images are the same when the segment type is ‘SCSegmentTypeImage’.
  3. Please make sure of the number of the titles, images and selected images are same when the segment type is ‘SCSegmentTypeTextImage’.

License

SCSegment is licensed under the terms of the MIT License.

Latest podspec

{
    "name": "SCSegment",
    "version": "1.0.1",
    "summary": "SCSegment supports setting up tabs with pictures using web pictures and local pictures.",
    "homepage": "https://github.com/Samueler/SCSegment",
    "license": "MIT",
    "authors": {
        "Samueler": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/Samueler/SCSegment.git",
        "tag": "1.0.1"
    },
    "source_files": [
        "SCSegment/Core",
        "SCSegment/Core/**/*.{h,m}"
    ],
    "dependencies": {
        "SDWebImage": [
            "~> 4.4.1"
        ]
    },
    "resources": "SCSegment/Core/Segment/Supporting/SCSegmentBundle.bundle"
}

Pin It on Pinterest

Share This