iPhone开发笔记
2012-02-17 09:57
239 查看
计算string串的像素长度:
利用这个函数可以根据String的像素长度来确定lable或者其他控件的width 和 height,从而实现lable的灵活定位.
使用图片设置View的背景
tableView默认是白色背景,如果要tableView的背景和底层View的背景颜色一致,需要将tableView的bgc Clear一下.
读取自定义的Cell的方法
首先定义相应Cell的一个标识符(如@"Cell"),这是一个静态字符串. 然后符合苹果reuse的特点,先在用对应标识符标记的Cell重用queue里面查找是否有可重用的Cell,有就返回相应的Cell,否则返回nil.这时就需要为这种标识符标记的Cell创建一个Cell实例.上面这个例子是从Cell的xib文件中读取构建相应的Cell.
获取屏幕的边界
bounds方法会返回整个屏幕的边界,包括状态栏所占用的控件;而applicationFrame方法则返回屏幕的可显示区域,不包括状态栏.
CGSize polLabelSize = [polName sizeWithFont:[UIFont boldSystemFontOfSize:16] constrainedToSize:CGSizeMake(MAXFLOAT, MAXFLOAT)]; CGSize podLabelSize = [podName sizeWithFont:[UIFont boldSystemFontOfSize:16] constrainedToSize:CGSizeMake(MAXFLOAT, MAXFLOAT)]; float polLabelWidth = (polLabelSize.width <= 125) ? polLabelSize.width : 125; float podLabelWidth = (podLabelSize.width <= 125) ? podLabelSize.width : 125; [polLabel setFrame:CGRectMake(10, 0, polLabelWidth, 32)]; [pageHeaderArrow setFrame:CGRectMake(polLabelWidth + 20, 7, 30, 20)]; [podLabel setFrame:CGRectMake(polLabelWidth + 60, 0, podLabelWidth, 32)];
利用这个函数可以根据String的像素长度来确定lable或者其他控件的width 和 height,从而实现lable的灵活定位.
使用图片设置View的背景
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]]]; [self.table setBackgroundColor:[UIColor clearColor]];
tableView默认是白色背景,如果要tableView的背景和底层View的背景颜色一致,需要将tableView的bgc Clear一下.
读取自定义的Cell的方法
static NSString *CellIdentifier = @"Cell"; HistoricalReliablityViewCellStyle *cell = (HistoricalReliablityViewCellStyle *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if(cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"HistoricalReliablityViewCellStyle" owner:self options:nil]; cell = [nib objectAtIndex:0]; cell.selectionStyle = UITableViewCellSelectionStyleNone; }
首先定义相应Cell的一个标识符(如@"Cell"),这是一个静态字符串. 然后符合苹果reuse的特点,先在用对应标识符标记的Cell重用queue里面查找是否有可重用的Cell,有就返回相应的Cell,否则返回nil.这时就需要为这种标识符标记的Cell创建一个Cell实例.上面这个例子是从Cell的xib文件中读取构建相应的Cell.
获取屏幕的边界
CGRect screenBounds = [[UIScreen mainScreen]bounds]; CGRect screenBounds = [[UIScreen mainScreen]applicationFrame];
bounds方法会返回整个屏幕的边界,包括状态栏所占用的控件;而applicationFrame方法则返回屏幕的可显示区域,不包括状态栏.
相关文章推荐
- iPhone开发学习笔记003——UITableViewCell内容自适应高度
- iPhone开发笔记(1)MPMoviePlayerController的用法和播放时只有声音没有图像的解决办法
- IPhone 开发笔记第一天——对基础的学习
- iPhone客户端开发笔记(四)
- iPhone开发入门笔记(一)—快速入门
- iPhone开发笔记[5/50]-忘了写@synthesize语句所产生的严重后果
- iphone开发笔记六:gdatexml安装与配置
- iPhone客户端开发笔记(五)
- iPhone开发学习笔记通过UIView实现动画效果
- iPhone应用程序开发指南 学习笔记
- iPhone开发笔记 (4) 如何改变UITableViewCell的行高
- iOS开发笔记14--iPhone消息推送机制实现与探讨
- iPhone开发学习笔记-Interface Builder
- iphone开发小笔记:iphone开发-地图注解(地图上的大头针)
- ios开发笔记:如何在iphone/ipad应用程序添加iAd
- iphone开发笔记目录
- iphone 开发学习笔记二
- iphone开发 小白笔记 1
- 献给iphone开发的同仁们,同时也给自己做个笔记
- iPhone开发笔记 退回输入键盘:自定义颜色:隐藏状态栏: