xib和初始化方法
来源:互联网 发布:博弈论诡计全集淘宝 编辑:程序博客网 时间:2024/05/13 13:13
先上代码
+ (MeetTableViewCell *)cellFromNib
{
MeetTableViewCell *cell = [[[NSBundlemainBundle]loadNibNamed:@"MeetTableViewCell"owner:selfoptions:nil]objectAtIndex:0];
return cell;
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder
{
self=[superinitWithCoder:aDecoder];
if (self) {
self = [[[NSBundlemainBundle]loadNibNamed:@"MeetTableViewCell"owner:selfoptions:nil]objectAtIndex:0];
}
return self;
}
和自定义xib用什么方法初始化
- (void)viewDidLoad { [super viewDidLoad]; UIImageView *imageView=[[UIImageView alloc] initWithFrame:self.view.frame]; [self.view addSubview:imageView]; self.view.backgroundColor=[UIColor blueColor]; UIGraphicsBeginImageContext(imageView.frame.size); [imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 15.0); //线宽 CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0); //颜色 CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 100, 100); //起点坐标 CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), 200, 100); //终点坐标 CGContextStrokePath(UIGraphicsGetCurrentContext()); imageView.image=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } ‘
自己写的在button上绘制两个圆
UIImageView *imageView1=[[UIImageView alloc] initWithFrame:CGRectMake(0 , 0, kCircleDiameter, kCircleDiameter)];
UIGraphicsBeginImageContext(imageView1.frame.size);
[imageView1.image drawInRect:CGRectMake(0, 0, button.frame.size.width, button.frame.size.height)];
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(),0,0,0,1.0);//画笔线的颜色
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 1.0);//线的宽度
CGContextAddArc(UIGraphicsGetCurrentContext(), kCircleDiameter/2, kCircleDiameter/2, kCircleDiameter/2-5, 0, 2*PI, 0);
CGContextDrawPath(UIGraphicsGetCurrentContext(), kCGPathStroke);
CGContextAddArc(UIGraphicsGetCurrentContext(), kCircleDiameter/2, kCircleDiameter/2, kCircleDiameter/4, 0, 2*PI, 0);
CGContextDrawPath(UIGraphicsGetCurrentContext(), kCGPathFill);
imageView1.image=UIGraphicsGetImageFromCurrentImageContext();
[button setBackgroundImage:imageView1.image forState:UIControlStateSelected];
- xib和初始化方法
- 用xib加载初始化要在awakeFromNib方法里实现
- xib作为cell的两种初始化方法
- Xcode改成不用MainWindow.xib 和 RootViewController.xib 的方法
- Xcode改成不用MainWindow.xib 和 RootViewController.xib 的方法
- awakeFromNib (XIB view 的初始化)
- 对象从xib中创建初始化完毕的时会调用的方法
- 继承自UIView的控件如何使用xib以及xib关联属性和方法
- Swift - 类初始化和反初始化方法
- xcode4.2 下xib文件和ViewController绑定方法
- 使用xib界面与和代码相关联的方法
- 使用xib界面与和代码相关联的方法
- OC3_继承和初始化方法
- 加载XIB的方法
- Objective-C 中便利初始化方法和指定初始化方法
- Spring中bean初始化时机初始化方法和销毁方法
- storyboard 和 xib
- Xib和storyboard对比
- 动态规划-时间规整算法
- Qt中各个widget前后位置的设置
- Linux各种包安装命令
- AIX中The largest dump device is too small的处理
- linux网络编程之 select()的模型
- xib和初始化方法
- Android:linux下aapt使用
- Mac使用Git简易入门教程
- SAP ABAP编程 采购订单过账冲销
- Lex与Yacc学习(六)之lex & yacc (简单计算器程序) 运行
- Oracle逐行提交、批量提交及极限提速方法
- Oracle监听配置及访问方式完全解析
- linux网络编程之 poll
- DMA类型介绍