- 浏览: 318343 次
- 性别:
- 来自: 杭州
最新评论
-
atgoingguoat:
R.drawable.icon是LOG图
android九宫格实现 -
atgoingguoat:
android:src="@drawable/ico ...
android九宫格实现 -
修博龙泉:
旋转view:
CGAffineTransform at ...
动画-图片旋转 -
修博龙泉:
阻尼效果图片:
CALayer *layer = self.i ...
动画-图片旋转 -
bei-jin-520:
color]sdfsdfsdf
android九宫格实现
//
// CustomSegmentedViewController.m
// CustomSegmented
//
// Created by qian cheng on 12-1-12.
// Copyright 2012 __MyCompanyName__. All rights reserved.
//
#import "CustomSegmentedViewController.h"
#import "CQSegmentControl.h"
@implementation CustomSegmentedViewController
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
// Image And title
NSArray *titleItems = [NSArray arrayWithObjects:NSLocalizedStringFromTable(@"Boy", @"XXXX...这就不写了", nil),
NSLocalizedStringFromTable(@"Girl", @"XXXX...这就不写了", nil), nil];
UIImage *normal_left = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_normal" ofType:@"png"]];
UIImage *normal_right = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"right_normal" ofType:@"png"]];
NSMutableArray *unselectImages = [[NSMutableArray alloc]initWithObjects:normal_left, normal_right, nil];
[normal_left release];
[normal_right release];
UIImage *select_left = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_press" ofType:@"png"]];
UIImage *select_right = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"right_press" ofType:@"png"]];
NSMutableArray *selectImages = [[NSMutableArray alloc]initWithObjects: select_left, select_right, nil];
[select_left release];
[select_right release];
CQSegmentControl *_segmentedControl= [[CQSegmentControl alloc] initWithItemsAndStype:titleItems stype:TitleAndImageSegmented];
for (UIView *subView in _segmentedControl.subviews)
{
[subView removeFromSuperview];
}
_segmentedControl.normalImageItems = unselectImages;
[unselectImages release];
_segmentedControl.highlightImageItems = selectImages;
[selectImages release];
_segmentedControl.selectedSegmentIndex = 1;
_segmentedControl.frame = CGRectMake(100.0f, 80.0f, 130.0f, 30.0f);
_segmentedControl.selectedItemColor = [UIColor whiteColor];
_segmentedControl.unselectedItemColor = [UIColor grayColor];
[_segmentedControl addTarget:self action:@selector(test:) forControlEvents:UIControlEventValueChanged];
_segmentedControl.font = [UIFont systemFontOfSize:14];
[self.view addSubview:_segmentedControl];
[_segmentedControl release];
//Title
NSArray *titleItem = [NSArray arrayWithObjects:NSLocalizedStringFromTable(@"Boy", @"XXXX...这就不写了", nil),
NSLocalizedStringFromTable(@"Girl", @"XXXX...这就不写了", nil), nil];
CQSegmentControl *_segmented= [[CQSegmentControl alloc] initWithItemsAndStype:titleItem stype:NormalSegmented];
for (UIView *subView in _segmented.subviews)
{
[subView removeFromSuperview];
}
_segmented.selectedSegmentIndex = 1;
_segmented.frame = CGRectMake(100.0f, 180.0f, 130.0f, 30.0f);
_segmented.selectedItemColor = [UIColor whiteColor];
_segmented.unselectedItemColor = [UIColor blueColor];
[_segmented addTarget:self action:@selector(test:) forControlEvents:UIControlEventValueChanged];
_segmented.font = [UIFont systemFontOfSize:14];
[self.view addSubview:_segmented];
[_segmented release];
//image
UIImage *normal_left_1 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_normal" ofType:@"png"]];
UIImage *normal_right_2 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"right_normal" ofType:@"png"]];
NSMutableArray *test = [[NSMutableArray alloc]initWithObjects:normal_left, normal_right, nil];
[normal_left_1 release];
[normal_right_2 release];
CQSegmentControl *_segmented_test= [[CQSegmentControl alloc] initWithItemsAndStype:test stype:NormalSegmented];
[test release];
for (UIView *subView in _segmented_test.subviews)
{
[subView removeFromSuperview];
}
_segmented_test.selectedSegmentIndex = 1;
_segmented_test.frame = CGRectMake(100.0f, 280.0f, 130.0f, 30.0f);
_segmented_test.selectedItemColor = [UIColor yellowColor];
_segmented_test.unselectedItemColor = [UIColor orangeColor];
[_segmented_test addTarget:self action:@selector(test:) forControlEvents:UIControlEventValueChanged];
_segmented_test.font = [UIFont systemFontOfSize:14];
[self.view addSubview:_segmented_test];
[_segmented_test release];
}
- (void)test:(id)sender
{
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
// CustomSegmentedViewController.m
// CustomSegmented
//
// Created by qian cheng on 12-1-12.
// Copyright 2012 __MyCompanyName__. All rights reserved.
//
#import "CustomSegmentedViewController.h"
#import "CQSegmentControl.h"
@implementation CustomSegmentedViewController
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
// Image And title
NSArray *titleItems = [NSArray arrayWithObjects:NSLocalizedStringFromTable(@"Boy", @"XXXX...这就不写了", nil),
NSLocalizedStringFromTable(@"Girl", @"XXXX...这就不写了", nil), nil];
UIImage *normal_left = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_normal" ofType:@"png"]];
UIImage *normal_right = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"right_normal" ofType:@"png"]];
NSMutableArray *unselectImages = [[NSMutableArray alloc]initWithObjects:normal_left, normal_right, nil];
[normal_left release];
[normal_right release];
UIImage *select_left = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_press" ofType:@"png"]];
UIImage *select_right = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"right_press" ofType:@"png"]];
NSMutableArray *selectImages = [[NSMutableArray alloc]initWithObjects: select_left, select_right, nil];
[select_left release];
[select_right release];
CQSegmentControl *_segmentedControl= [[CQSegmentControl alloc] initWithItemsAndStype:titleItems stype:TitleAndImageSegmented];
for (UIView *subView in _segmentedControl.subviews)
{
[subView removeFromSuperview];
}
_segmentedControl.normalImageItems = unselectImages;
[unselectImages release];
_segmentedControl.highlightImageItems = selectImages;
[selectImages release];
_segmentedControl.selectedSegmentIndex = 1;
_segmentedControl.frame = CGRectMake(100.0f, 80.0f, 130.0f, 30.0f);
_segmentedControl.selectedItemColor = [UIColor whiteColor];
_segmentedControl.unselectedItemColor = [UIColor grayColor];
[_segmentedControl addTarget:self action:@selector(test:) forControlEvents:UIControlEventValueChanged];
_segmentedControl.font = [UIFont systemFontOfSize:14];
[self.view addSubview:_segmentedControl];
[_segmentedControl release];
//Title
NSArray *titleItem = [NSArray arrayWithObjects:NSLocalizedStringFromTable(@"Boy", @"XXXX...这就不写了", nil),
NSLocalizedStringFromTable(@"Girl", @"XXXX...这就不写了", nil), nil];
CQSegmentControl *_segmented= [[CQSegmentControl alloc] initWithItemsAndStype:titleItem stype:NormalSegmented];
for (UIView *subView in _segmented.subviews)
{
[subView removeFromSuperview];
}
_segmented.selectedSegmentIndex = 1;
_segmented.frame = CGRectMake(100.0f, 180.0f, 130.0f, 30.0f);
_segmented.selectedItemColor = [UIColor whiteColor];
_segmented.unselectedItemColor = [UIColor blueColor];
[_segmented addTarget:self action:@selector(test:) forControlEvents:UIControlEventValueChanged];
_segmented.font = [UIFont systemFontOfSize:14];
[self.view addSubview:_segmented];
[_segmented release];
//image
UIImage *normal_left_1 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_normal" ofType:@"png"]];
UIImage *normal_right_2 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"right_normal" ofType:@"png"]];
NSMutableArray *test = [[NSMutableArray alloc]initWithObjects:normal_left, normal_right, nil];
[normal_left_1 release];
[normal_right_2 release];
CQSegmentControl *_segmented_test= [[CQSegmentControl alloc] initWithItemsAndStype:test stype:NormalSegmented];
[test release];
for (UIView *subView in _segmented_test.subviews)
{
[subView removeFromSuperview];
}
_segmented_test.selectedSegmentIndex = 1;
_segmented_test.frame = CGRectMake(100.0f, 280.0f, 130.0f, 30.0f);
_segmented_test.selectedItemColor = [UIColor yellowColor];
_segmented_test.unselectedItemColor = [UIColor orangeColor];
[_segmented_test addTarget:self action:@selector(test:) forControlEvents:UIControlEventValueChanged];
_segmented_test.font = [UIFont systemFontOfSize:14];
[self.view addSubview:_segmented_test];
[_segmented_test release];
}
- (void)test:(id)sender
{
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
发表评论
-
CCMenu 与 CCMenuItem
2013-11-09 11:52 870引入#import "ccDeprecate ... -
抛物线的精灵
2013-11-08 15:04 825// 抛物线 //mSprite:需要做抛物线的精灵 ... -
卡马克卷轴算法
2013-11-05 15:35 2129念 这里使用简化的概念,精确的定义请参考计算机图形学中二维观察 ... -
git 大招
2013-11-04 19:54 1582Last login: Mon Nov 4 19:30:1 ... -
AVAudioRecorder MAV格式录音
2013-08-15 21:13 1215//录音设置 NSDictionary * ... -
uilable根据字符串长度变化
2013-08-01 15:18 917CGSize labelSize = [ ... -
ios 文本自动换行
2013-07-30 19:52 1062// //自动换行 // UILabel *l ... -
ios 文本框随着键盘高度变化而变化
2013-07-29 18:22 2275监听键盘高度变化 [[NSNotificationC ... -
IOS开发苹果官方Sample Code及下载地址
2013-07-11 11:17 1619在线浏览地址:https://developer.apple ... -
苹果推送通知服务(APNs)编程(转)
2013-06-07 11:19 1315iPhone 对于应用程序在后台运行有诸多限制(除非你越狱) ... -
cell 数据重复
2013-06-03 15:21 1046static NSString *CellIdentifi ... -
ios NSDate NSTring long 时间戳与字符串转换
2013-05-22 11:09 27021一,转化的方法为 NSString *timeS ... -
关于缺少各种framework出现的错误累结(转)
2013-05-16 16:47 1416博客分类: iosiPhone开发 iosiPhone开发 ... -
动画-图片旋转
2013-05-13 11:28 1466旋转: iv = [[UIImageView alloc] ... -
UINavicationController
2013-05-13 09:41 909如果楼主想要使用UINavigationController中 ... -
NSTimer-动态修改Interval的值
2013-05-06 09:38 931NSTimer使用例子: NSTimer *sh ... -
UIScrollView的属性总结
2013-04-27 10:00 948UIScrollView的属性总结 属性 作用 CGPoint ... -
单例设置
2013-04-27 09:51 838+ (RootScrollView *)shareIn ... -
颜色设置
2013-04-27 09:50 722[Globle colorFromHexRGB:@&quo ... -
翻转动画
2013-04-11 16:11 817CGContextRef context ...
相关推荐
这个“分段按键设置”实例旨在教你如何自定义UISegmentControl,使其在用户点击不同段时触发不同的事件。下面将详细介绍这个知识点及其相关技术。 首先,UISegmentControl是一个显示一系列选项的视图,每个选项称为...
来源:github/YYSegmentControlLicence:Apache 2.0作者:向文品 Swift 语言编写自定义 UISegmentControl 控件, 使用更加灵活,可自定义边角形状半径、颜色、等多样化的Segment。
2. 替代系统的UISegmentControl,且功能更加强大; 3. 仿网易、搜狐等新闻客户端的可滑动的内容视图和TabBar,支持滑动内容视图时,对应TabItem的字体、颜色、选中背景跟随内容视图的滚动进行平滑渐变切换。
iOS提供的控件UISegmentControl可以通过setBackgroundImage、...但在处理圆角和按下状态时效果不太理想,所以实现了一个自定义控件,它继承UIButton,使用方法和系统UISegmentControl类似,支持点击和拖动。
2. 替代系统的UISegmentControl,且功能更加强大; 3. 仿网易、搜狐等新闻客户端的可滑动的内容视图和TabBar,支持滑动内容视图时,对应TabItem的字体、颜色、选中背景跟随内容视图的滚动进行平滑渐变切换; 4. 多...
自定义分段控制 JRSegmentControl ,一个类似于UISegmentControl的自定义控制,可以点击和滑动来切换不同的选项。同时封装了J...
源码YYSegmentControl,Swift 语言编写自定义控件 实现类似于UISegmentControl的功能 但是使用更加灵活 可自定义边角形状半径 颜色 等多样化的Segment 我只是Objective-C -> Swift 的搬运工
2. 替代系统的UISegmentControl,且功能更加强大; 3. 仿网易、搜狐等新闻客户端的可滑动的内容视图和TabBar,支持滑动内容视图时,对应TabItem的字体、颜色、选中背景跟随内容视图的滚动进行平滑渐变切换。
YPTabBarController 一款功能十分强大TabBarController,几乎你所能想到的关于TabBar的需求,它都能实现。 ##安装方法: pod 'YPTabBarController' 或者, 直接将YPTabBarController...替代系统的UISegmentControl,
然而,标准的`UISegmentControl`并不具备自动滚动到中间的特性,所以这个项目通过自定义`SegmentControl`来扩展其功能。 自定义`SegmentControl`的过程通常包括以下几个步骤: 1. **创建自定义视图**:首先,你...
首先,Segment Control的基本使用是在Interface Builder或代码中创建一个UISegmentControl对象,并添加相应的标题或图像。然而,为了实现自定义效果,我们需要在代码中进行更多的操作。你可以通过设置`tintColor`、`...
首先,CLSegmentViewController的核心功能是对传统的UISegmentControl进行了扩展,不仅支持文字、图片的显示,还可以自定义每个分段的样式和交互效果。这样的设计使得分段控制器在视觉上更加吸引人,同时能够更好地...
SHSegmentControl可能是作者自定义实现的一个组件,用于替代系统默认的UISegmentControl,可能具有更丰富的定制性和样式。 【描述】描述提到,由于文件数量较多,无法逐一验证其可用性,这意味着这个压缩包可能包含...
首先,LBSegmentControl的核心功能在于提供一个类似苹果原生UISegmentControl的组件,但其拥有更多的自定义选项。开发者可以根据自己的需求调整颜色、字体、选中状态、滑动效果等视觉元素,从而实现与应用整体风格相...
- Swift中的`UISegmentControl`是iOS系统提供的分段控制器,但为了达到微博的效果,我们通常需要对其进行自定义,包括调整样式、添加动画效果等。这可能涉及到创建自定义的Segment Control类,重写其draw方法来实现...
3. 在iOS中,SegmentControl通常使用UISegmentControl类来创建,该类提供了自定义颜色、字体、大小和样式的能力。 关于实现SegmentControl的关键知识点: 1. 创建实例:使用代码或者Storyboard中的UIBuilder来创建...
在iOS中,可使用`UISegmentControl`或自定义滑动视图。 3. **聊天界面**:聊天界面的核心是消息列表和输入框。Android中的`RecyclerView`或iOS的`UITableView`可以用来展示消息历史,每个消息项需要自定义视图以...
4. **内容视图**:与原生的UISegmentControl不同,SunSegmentView可以方便地添加自定义视图作为每个Segment的内容,这在展示复杂信息或者按钮组时非常有用。 5. **API简单易用**:SunSegmentView提供了简洁明了的...
4. **自定义外观**:为了提供更好的用户体验,开发者还可以自定义分段控件的外观。比如改变文字颜色、背景色、选中状态的样式,甚至可以更换图片作为段的标识。 5. **响应式布局**:在不同的屏幕尺寸和设备方向下,...