Git Product home page Git Product logo

sgsegmentedcontrol's Introduction

前沿

  • 新闻、电商、视频等 app 经常会看到这种 SegmentedControl 布局样式

  • 这里的 SegmentedControl 采取的是腾讯新闻、网易新闻、礼物说、淘宝(微淘界面)、京东(发现界面)等布局样式

  • 轻轻的我走了,正如我轻轻的来,我动一动鼠标,就是为了给你 Star (喜欢的朋友别忘了哦 😊 😊)

  • 代码后期不断更新维护中(会增加类似贝贝、腾讯视频动态改变指示器的宽度)

主要内容的介绍

  • 静止状态下标题按钮

  • 滚动状态下标题按钮

  • 静态状态下带有图片的标题按钮

  • 滚动状态下带有图片的标题按钮

  • 指示器样式

  • 指示器样式二

  • 标题按钮文字渐显效果

  • 标题按钮文字缩放效果

  • 导航栏标题按钮的创建

效果图

代码介绍

* SGSegmentedControl的使用

  • 将项目中SGSegmentedControl文件夹拖入工程

  • 导入#import "SGSegmentedControl.h"头文件

  • 对象方法创建

普通状态下的对象方法创建

- (instancetype)initWithFrame:(CGRect)frame delegate:(id<SGSegmentedControlDelegate>)delegate segmentedControlType:(SGSegmentedControlType)segmentedControlType titleArr:(NSArray *)titleArr;
带有图片的对象方法创建

- (instancetype)initWithFrame:(CGRect)frame delegate:(id<SGSegmentedControlDelegate>)delegate segmentedControlType:(SGSegmentedControlType)segmentedControlType nomalImageArr:(NSArray *)nomalImageArr selectedImageArr:(NSArray *)selectedImageArr titleArr:(NSArray *)titleArr;
  • 类方法创建
普通状态下的类方法创建

+ (instancetype)segmentedControlWithFrame:(CGRect)frame delegate:(id<SGSegmentedControlDelegate>)delegate segmentedControlType:(SGSegmentedControlType)segmentedControlType titleArr:(NSArray *)titleArr;
带有图片的类方法创建

+ (instancetype)segmentedControlWithFrame:(CGRect)frame delegate:(id<SGSegmentedControlDelegate>)delegate segmentedControlType:(SGSegmentedControlType)segmentedControlType nomalImageArr:(NSArray *)nomalImageArr selectedImageArr:(NSArray *)selectedImageArr titleArr:(NSArray *)titleArr;
  • 属性设置

  • @property (nonatomic, assign) SGSegmentedControlType segmentedControlType; // 枚举属性, 默认为滚动风格

  • @property (nonatomic, strong) UIColor *titleColorStateNormal; // 标题文字颜色(默认为黑色)

  • @property (nonatomic, strong) UIColor *titleColorStateSelected; // 选中时标题文字颜色(默认为红色)

  • @property (nonatomic, strong) UIColor *indicatorColor; // 指示器的颜色(默认为红色)

  • @property (nonatomic, assign) BOOL showsBottomScrollIndicator; // 是否显示底部滚动指示器(默认为YES, 显示)

  • @property (nonatomic, assign) SGSegmentedControlIndicatorType segmentedControlIndicatorType; // 枚举属性, 指示器样式(默认为底部样式)

  • -(void)titleBtnSelectedWithScrollView:(UIScrollView *)scrollView; // 标题选中颜色改变以及指示器位置变化

  • @property (nonatomic, assign) BOOL titleColorGradualChange; // 标题文字渐变效果(默认为NO), 与titleBtnColorGradualChangeScrollViewDidScroll方法,一起才会生效

  • @property (nonatomic, assign) BOOL titleFondGradualChange; // 标题文字缩放效果(默认为NO), 与titleBtnColorGradualChangeScrollViewDidScroll方法,一起才会生效

  • -(void)titleBtnColorGradualChangeScrollViewDidScroll:(UIScrollView *)scrollView; // 给外界scrollViewDidScroll方法提供文字渐显效果

  • 遵循SGSegmentedControlDelegate协议的delegate_SG方法

- (void)SGSegmentedControl:(SGSegmentedControl *)segmentedControl didSelectBtnAtIndex:(NSInteger)index;
  • 提示信息文字,根据内容自动调节
- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(nullable NSDictionary *)attributes context:(nullable NSStringDrawingContext *)context;

版本介绍

      1. 7 --> 初始版本的创建

Concluding remarks

sgsegmentedcontrol's People

Contributors

kingsic avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.