使用HMSegmentedControl实现分段控件
郝萌主倾心贡献,尊重作者的劳动成果,请勿转载。
如果文章对您有所帮助,欢迎给作者捐赠,支持郝萌主,捐赠数额随意,重在心意^_^
我要捐赠: 点击捐赠
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
andHMSegmentedControl.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实现分段控件相关推荐
- java+tableseg,多种功能集成,带Refresh刷新的tableV,Seg分段控件
支持 IOS7+ 详见Demo TestSegmentAndRefreshTableViewDemo 多种功能集成,带Refresh刷新的tableV,Seg分段控件,加载提示toast ##使用到 ...
- android标签循环,iOS和Android规范解析——标签导航和分段控件
从今天开始,将介绍iOS和Android设计规范中关于导航的部分.今天要介绍的两个控件,经常容易混淆以至于用错.请各位读者仔细阅读,防止以后用错. Material Design Guidelines ...
- 状态控件ios 中滑块、开关、分段控件、操作表和警告的常用函数
PS:今天上午,非常郁闷,有很多简单基础的问题搞得我有些迷茫,哎,代码几天不写就忘.目前又不当COO,还是得用心记代码哦! 对于SLider通过value属性可以到得以后滑块的值 UISlider * ...
- macOS SwiftUI 选择器组件规范之 01 分段控件Segmented Controls
macOS SwiftUI 选择器组件规范之 01 分段控件 什么是分段控件(Segmented Controls) 分段控件是两个或多个分段的水平集合,每个分段都充当一个按钮-通常是一个切换按钮.分 ...
- UIControl IOS控件编程 及UITextField的讲解
第一部分 UIKit提供了一组控件:UISwitch开关.UIButton按钮.UISegmentedControl分段控件.UISlider滑块.UITextField文本字段控件.UIPageCo ...
- iOS基本UI控件总结
包括以下几类: //继承自NSObject:(暂列为控件) UIColor *_color; //颜色 UIImage *_image; //图像 //继承自UIView:只能相应手势UI ...
- 【IOS 开发】基本 UI 控件详解 (UISegmentedControl | UIImageView | UIProgressView | UISlider | UIAlertView )
转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/50163725 一. 分段控件 (UISegmentedControl) 控件展 ...
- 控件与组件的区别_5分钟学交互:手机交互组件归纳 导航篇
个人公众号:鱼大大设计铺,ID:ydsjp2018 转载请私信作者,并注明来源公众号:沐风与体验设计 交互设计其实就是根据产品目标和用户目标,选择最合适的导航结构.页面结构.交互控件以及动效.这个任务 ...
- wpf 点击某控件范围之外的区域 该控件隐藏_iOS平台设计规范(八)控件Controls...
无论是UI.交互,还是产品经理,都应该熟读iOS平台设计规范.这对我们的产品设计,百利而无一弊. 控件(Controls) 一.按钮(Buttons) 按钮常用于触发特定操作,可自定义的背景颜色 ...
最新文章
- Linux学习(二)--远程登录Linux系统
- c++加载python模块,但是PyImport_ImportModule老返回NULL
- opencv recipe for target 'all' failed解决
- 【转】Photoshop网站设计:DesignStudio
- js动态渲染html页面,利用Scrapy-Splash抓取JS动态渲染的网页数据
- python字典的键有什么要求_在Python中使用范围作为字典键,我有什么选择?
- Undefined reference to ...
- logrotate 不生效
- PHP $_SERVER详解
- Maven 镜像设置
- 基本知识 100176
- sql语句动态拼接多个查询条件查询数据库
- /etc/login.defs配置文件详解
- 畜牧业适宜性评价算法
- 剑指 Offer 32 - I. 从上到下打印二叉树(Java迭代法实现)
- opencv实现色彩还原(白平衡)
- 聚美自建的“真品联盟”被京东捅破的窗户纸
- 南信与南邮谁的计算机专业更强,南信力压南邮!关于一流本科专业!
- docker容器里无法使用vi命令
- 为华为荣耀5c(nem-tlooh)编译最新twrp recovery