日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用HMSegmentedControl实现分段控件

發布時間:2025/7/14 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用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?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实现分段控件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。