iOS开发中用到的控件(一)
2014-03-06 21:36
113 查看
控件一:圆形图片
@interface UIImage (CircleImage)
-(UIImage *) circleImageWithParam:(CGFloat) inset;
@end
@implementation UIImage (CircleImage)
-(UIImage *) circleImageWithParam:(CGFloat) inset {
UIGraphicsBeginImageContext(CGSizeMake(104,
104));
CGContextRef context =
UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context,
2);
CGContextSetStrokeColorWithColor(context, [UIColor
orangeColor].CGColor);
CGRect rect = CGRectMake(inset, inset,
94, 94);
CGContextAddEllipseInRect(context, rect);
CGContextClip(context);
[self drawInRect:rect];
// CGContextAddEllipseInRect(context, rect);
// CGContextStrokePath(context);
UIImage *newimg =
UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newimg;
}
@end
控件二:导航条返回按钮
@interface UIBarButtonItem (CustomBackItem)
+ (UIBarButtonItem *)backArrowButtonWithTarget:(id)target action:(SEL)action;
@end
@implementation UIBarButtonItem (CustomBackItem)
+ (UIBarButtonItem *)backArrowButtonWithTarget:(id)target action:(SEL)action
{
UIImage *buttonImage = [UIImage
imageNamed:@"go_back.png"];
//create the button and assign the image
UIButton *button = [UIButton
buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage
forState:UIControlStateNormal];
//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0,
0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:target
action:action forControlEvents:UIControlEventTouchUpInside];
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem
alloc] initWithCustomView:button];
return [customBarItem
autorelease];
}
@interface UIImage (CircleImage)
-(UIImage *) circleImageWithParam:(CGFloat) inset;
@end
@implementation UIImage (CircleImage)
-(UIImage *) circleImageWithParam:(CGFloat) inset {
UIGraphicsBeginImageContext(CGSizeMake(104,
104));
CGContextRef context =
UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context,
2);
CGContextSetStrokeColorWithColor(context, [UIColor
orangeColor].CGColor);
CGRect rect = CGRectMake(inset, inset,
94, 94);
CGContextAddEllipseInRect(context, rect);
CGContextClip(context);
[self drawInRect:rect];
// CGContextAddEllipseInRect(context, rect);
// CGContextStrokePath(context);
UIImage *newimg =
UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newimg;
}
@end
控件二:导航条返回按钮
@interface UIBarButtonItem (CustomBackItem)
+ (UIBarButtonItem *)backArrowButtonWithTarget:(id)target action:(SEL)action;
@end
@implementation UIBarButtonItem (CustomBackItem)
+ (UIBarButtonItem *)backArrowButtonWithTarget:(id)target action:(SEL)action
{
UIImage *buttonImage = [UIImage
imageNamed:@"go_back.png"];
//create the button and assign the image
UIButton *button = [UIButton
buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage
forState:UIControlStateNormal];
//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0,
0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:target
action:action forControlEvents:UIControlEventTouchUpInside];
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem
alloc] initWithCustomView:button];
return [customBarItem
autorelease];
}
相关文章推荐
- IOS开发经常用到齐全控件
- ios 开发中经常用到的 栏控件(bar) 有哪些呢?
- ios 开发中经常用到的 栏控件(bar)
- IOS开发--循环引用问题,普通控件为什么用weak,代理为什么用weak,block内用到外面的东
- IOS开发之因Cell重用导致控件的状态级联改变
- iOS开发-UI控件:如何画1像素的线
- iOS开发UI篇—UITableview控件使用小结
- iOS开发基础控件--UILabel
- 汇总iOS开发中需要用到的开源库
- iOS开发技巧 - 使用和定制开关控件(UISwitch)
- iOS开发中Date Picker和UITool Bar控件的使用简介
- IOS开发-代码创建UI控件并修改控件属性(代码创建UIButton、UILabel)
- iOS 开发基础常用控件介绍总结
- iOS开发可能用到的函数
- iOS开发中的错误整理,(百思项目,指示器位置)设置控件尺寸和点坐标,先设置尺寸,再设置点坐标
- iOS开发系列课程(06) --- 常用控件介绍
- iOS开发UI之日期控件的使用(UIDatePicker)
- iOS开发UI篇—手写控件,frame,center和bounds属性
- iOS基础控件之UISegmentedControl 分类: ios开发 2015-04-06 16:53 321人阅读 评论(0) 收藏
- iOS开发-控件设置