郝萌主倾心贡献,尊重作者的劳动成果,请勿转载。

如果文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额随意,重在心意^_^

我要捐赠: 点击捐赠

Cocos2d-X×××:点我传送

HMSegmentedControl 是 UISegmentedControl 的替代品,模仿了 Google Currents 使用的效果。

HMSegmentedControl

A drop-in replacement for UISegmentedControl mimicking the style of the segmented control used in Google Currents and various other Google products.

Features

  • Supports both text and images
  • Font and all colors are customizable
  • Supports selection indicator both on top and bottom
  • Supports blocks
  • Works with ARC and iOS >= 5

Installation

CocoaPods

The easiest way of installing HMSegmentedControl is via CocoaPods.

pod 'HMSegmentedControl', '~> 1.1.0' 

Cocoa-whaa?

If you haven't heard about CocoaPods (seriously, where were you?!), it's a dependency manager for Xcode projects that provides very simple installation of libraries. Here's how to get started.

Install CocoaPods if not already available:

$ [sudo] gem install cocoapods $ pod setup 

Change to the directory of your Xcode project, and Create and Edit your Podfile and add HMSegmentedControl:

$ cd /path/to/MyProject $ touch Podfile $ edit Podfile platform :ios, '5.0'  pod 'HMSegmentedControl', '~> 1.2.0' 

Install into your project:

$ pod install 

Open your project in Xcode from the .xcworkspace file (not the usual project file)

$ open MyProject.xcworkspace 

Old-fashioned way

  • Add HMSegmentedControl.h and HMSegmentedControl.m to your project.
  • Add QuartzCore.framework to your linked frameworks.
  • #import "HMSegmentedControl.h" where you want to add the control.

Usage

The code below will create a segmented control with the default looks:

    HMSegmentedControl *segmented = [[HMSegmentedControl alloc] initWithSectionTitles:@[@"已收公告",@"已发公告"]];     segmented.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth;     segmented.frame = CGRectMake(self.view.bounds.size.width/2-100, 4, 200, 40);     segmented.backgroundColor = [UIColor clearColor];     segmented.selectionIndicatorHeight = 3.0f;     segmented.font = [UIFont fontWithName:@"STHeitiSC-Light" size:19.0f];     segmented.textColor = WHRGB(255, 175, 185);     segmented.selectedTextColor = [UIColor whiteColor];     segmented.selectionIndicatorColor = [UIColor whiteColor];     segmented.selectionStyle = HMSegmentedControlSelectionStyleFullWidthStripe;     segmented.selectionIndicatorLocation = HMSegmentedControlSelectionIndicatorLocationDown;     [segmented addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];     self.segmentedControl = segmented;     [self.navigationController.navigationBar addSubview:segmented];

Included is a demo project showing how to fully customise the control.

郝萌主倾心贡献,尊重作者的劳动成果,请勿转载。

如果文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额随意,重在心意^_^

我要捐赠: 点击捐赠

Cocos2d-X×××:点我传送

转载于:https://blog.51cto.com/haomengzhu/1664344

使用HMSegmentedControl实现分段控件相关推荐

  1. java+tableseg,多种功能集成,带Refresh刷新的tableV,Seg分段控件

    支持 IOS7+  详见Demo TestSegmentAndRefreshTableViewDemo 多种功能集成,带Refresh刷新的tableV,Seg分段控件,加载提示toast ##使用到 ...

  2. android标签循环,iOS和Android规范解析——标签导航和分段控件

    从今天开始,将介绍iOS和Android设计规范中关于导航的部分.今天要介绍的两个控件,经常容易混淆以至于用错.请各位读者仔细阅读,防止以后用错. Material Design Guidelines ...

  3. 状态控件ios 中滑块、开关、分段控件、操作表和警告的常用函数

    PS:今天上午,非常郁闷,有很多简单基础的问题搞得我有些迷茫,哎,代码几天不写就忘.目前又不当COO,还是得用心记代码哦! 对于SLider通过value属性可以到得以后滑块的值 UISlider * ...

  4. macOS SwiftUI 选择器组件规范之 01 分段控件Segmented Controls

    macOS SwiftUI 选择器组件规范之 01 分段控件 什么是分段控件(Segmented Controls) 分段控件是两个或多个分段的水平集合,每个分段都充当一个按钮-通常是一个切换按钮.分 ...

  5. UIControl IOS控件编程 及UITextField的讲解

    第一部分 UIKit提供了一组控件:UISwitch开关.UIButton按钮.UISegmentedControl分段控件.UISlider滑块.UITextField文本字段控件.UIPageCo ...

  6. iOS基本UI控件总结

    包括以下几类: //继承自NSObject:(暂列为控件) UIColor *_color;    //颜色 UIImage *_image;    //图像 //继承自UIView:只能相应手势UI ...

  7. 【IOS 开发】基本 UI 控件详解 (UISegmentedControl | UIImageView | UIProgressView | UISlider | UIAlertView )

    转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/50163725 一. 分段控件 (UISegmentedControl) 控件展 ...

  8. 控件与组件的区别_5分钟学交互:手机交互组件归纳 导航篇

    个人公众号:鱼大大设计铺,ID:ydsjp2018 转载请私信作者,并注明来源公众号:沐风与体验设计 交互设计其实就是根据产品目标和用户目标,选择最合适的导航结构.页面结构.交互控件以及动效.这个任务 ...

  9. wpf 点击某控件范围之外的区域 该控件隐藏_iOS平台设计规范(八)控件Controls...

    无论是UI.交互,还是产品经理,都应该熟读iOS平台设计规范.这对我们的产品设计,百利而无一弊.    控件(Controls) 一.按钮(Buttons) 按钮常用于触发特定操作,可自定义的背景颜色 ...

最新文章

  1. Linux学习(二)--远程登录Linux系统
  2. c++加载python模块,但是PyImport_ImportModule老返回NULL
  3. opencv recipe for target 'all' failed解决
  4. 【转】Photoshop网站设计:DesignStudio
  5. js动态渲染html页面,利用Scrapy-Splash抓取JS动态渲染的网页数据
  6. python字典的键有什么要求_在Python中使用范围作为字典键,我有什么选择?
  7. Undefined reference to ...
  8. logrotate 不生效
  9. PHP $_SERVER详解
  10. Maven 镜像设置
  11. 基本知识 100176
  12. sql语句动态拼接多个查询条件查询数据库
  13. /etc/login.defs配置文件详解
  14. 畜牧业适宜性评价算法
  15. 剑指 Offer 32 - I. 从上到下打印二叉树(Java迭代法实现)
  16. opencv实现色彩还原(白平衡)
  17. 聚美自建的“真品联盟”被京东捅破的窗户纸
  18. 南信与南邮谁的计算机专业更强,南信力压南邮!关于一流本科专业!
  19. docker容器里无法使用vi命令
  20. 为华为荣耀5c(nem-tlooh)编译最新twrp recovery

热门文章

  1. Yii2中关于组件的注册以及创建的方法详解
  2. Linux 安装Resin4.0.40
  3. cefsharp wpf 中文输入问题解决方法
  4. mysql集群之MMM简单搭建
  5. [转]HTTP请求模型和头信息
  6. 瞎忙不如不忙——读高德拉特《目标》有感
  7. 20190404 Oracle忘记登陆密码
  8. xftp permission is not allowed
  9. php实现查询上传文件进度
  10. 杯具,丢失了一部分邮件