![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
UI控件系列
zhongxiangwh
这个作者很懒,什么都没留下…
展开
-
幻灯片效果+背景音乐
Iphone幻灯片效果+背景音乐今天弄了几张好看的图片,我就摸索着实现了图片的幻灯片效果,这个以前也实现过了,也算是温故知新吧,另外就是使用SoundEngine类实现背景音乐的播放。SoundEngine类可以从[url=read.php?tid-1215.html]http://www.cocoachina.com/bbs/read.php?tid-1215.html[/url]下载到。转载 2012-05-02 14:30:36 · 384 阅读 · 0 评论 -
在UITableView右侧添加索引
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{ return [[theDataDict allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; //若要添加一个搜索图标在顶部可以: N转载 2012-05-22 16:22:07 · 1233 阅读 · 0 评论 -
CATransition 的初级应用
需要在frameworks中添加QuartzCore.framework在接口程序中加上头文件 #import /*好多动画效果*/ CATransition *transition = [CATransition animation]; transition.duration = 1.0f; /* 间隔时间*/ transition.转载 2012-05-16 10:06:02 · 282 阅读 · 0 评论 -
让label自适应里面的文字,自动调整宽度和高度。
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];这个frame是初设的,没关系,后面还会重新设置其size。[label setNumberOfLines:0];NSString *s = @"string......";UIFont *font = [UIFont fontWithName:@"转载 2012-05-03 09:32:44 · 671 阅读 · 0 评论 -
更改cell选中后的颜色
cell.selectionStyle = UITableViewCellSelectionStyleGray;转载 2012-05-03 09:32:00 · 245 阅读 · 0 评论 -
在tableview中选种一行,当失去焦点的时候选种行的颜色自动消失
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{[table deselectRowAtIndexPath:[table indexPathForSelectedRow] animated:YES];}转载 2012-05-03 09:31:30 · 1422 阅读 · 1 评论 -
UIWebView
UIWebView是iOS sdk中一个最常用的控件。是内置的浏览器控件,我们可以用它来浏览网页、打开文档等等 用UIWebView在当前程序中打开网页NSString *query = [NSString stringWithFormat:@"http://www.baidu.com?q=苹果"]; NSString *strUrl = [query stringByAdd转载 2012-05-03 09:30:55 · 321 阅读 · 0 评论 -
实现自适应高度的 UITableViewCell 或 UILabel
在iphone开发中处理table时常常会有这样的问题,table中cell的高度不是固定的,而是是根据其中的内容不同而不同的。对与这种情况,sdk本身并没有很好的支持,经过一翻摸索,发现大家通常的做法都是在实现 heightForRowAtIndexPath 方法时,根据内容计算出来显示的高度。幸运的是,nsstring内置了几个好用的函数可以方便的计算出来字符串被现实出来时占有的屏幕高度:转载 2012-05-03 09:26:26 · 267 阅读 · 0 评论 -
UITableViewCell
UITableView 的 cell 默认出现在 uitableview 的第一行,如果你想自定义 UITableViewCell 与导航条间距的话,可以使用下面这行代码 tableview.tableHeaderView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 5, 20)]autorelease];转载 2012-05-03 09:30:06 · 241 阅读 · 0 评论 -
UIView 的 autoresizingMask 属性 详解。
在 UIView 中有一个autoresizingMask的属性,它对应的是一个枚举的值(如下),属性的意思就是自动调整子控件与父控件中间的位置,宽高。enum { UIViewAutoresizingNone = 0, UIViewAutoresizingFlexibleLeftMargin = 1 UIViewAutoresiz转载 2012-05-02 09:33:42 · 396 阅读 · 0 评论 -
UITextField
//属性设置UITextField* text = [[UITextField alloc] initWithFrame:CGRectMake(10, 50, 300, 30)]; text.borderStyle = UITextBorderStyleRoundedRect;//设置文本框边框风格 text.autocorrectionType = UITextAutoc转载 2012-05-02 14:21:46 · 550 阅读 · 0 评论 -
UIButton按钮控件
1、动态创建//创建按钮 UIButton *sampleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; //设置按钮位置 [sampleButton setFrame:CGRectMake(10, 100, self.view.bounds.size.width- 20, 52转载 2012-05-02 14:22:35 · 1007 阅读 · 0 评论 -
UIImageView控件使用详解
UIImageView:可以通过UIImage加载图片赋给UIImageView,加载后你可以指定显示的位置和大小。1、初始化UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.0,45.0,300,300)];imageView.image = [UIImage imageNamed:@"转载 2012-05-02 14:25:08 · 334 阅读 · 0 评论 -
UILable控件
1、 UILabel 使用 NSString 显示文字------代码创建Label {//定义标签的位置和尺寸,位置:x=0.0f, y=0.0f ,尺寸:x=320.0f, y=30.0f UILabel *Label = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 30.0f)];转载 2012-05-02 14:27:01 · 244 阅读 · 0 评论 -
UIscrollView
contentSize是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset转载 2012-05-02 14:23:33 · 348 阅读 · 0 评论 -
bounds和frame的差别
什么是绝对坐标值,相对坐标值?绝对坐标是:X,Y 就是相对于坐标原点的。 bounds是指这个view在它自己坐标系的坐标和大小 而frame指的是这个view在它superview的坐标系的坐标和大小,区别主要在坐标系这一块。frame 是相对坐标。bounds是绝对坐标。很明显,bounds的原点是(0,0)点,而frame的原点却是任意的。frame 如转载 2012-05-02 14:31:32 · 205 阅读 · 0 评论 -
UINavigationController导航
1、导航错位问题iPhone的状态栏可以设置成半透明, 这是众所周知的, 用UINavigationController,在页面切换时, 如果你的子viewController的view是全屏的(480*320) 就会出现错位, 表现是所以的子view会向下偏移了 20像素 (就是状态栏的高度).我搜索了好长时间也没有找到答案, 于是自己去看官方文档, 结果发现了这个方法, 这是UIVie转载 2012-05-02 14:25:50 · 421 阅读 · 0 评论 -
UITextView控件的用法详解
UITextView控件的用法详解1.创建并初始化创建UITextView的文件,并在.h文件中写入如下代码:1 #import 3 @interface TextViewController : UIViewController {4 UITextView *textView;5 }7 @property (nonatomic, r转载 2012-05-02 14:29:30 · 304 阅读 · 0 评论 -
UITableView,UITableViewCell,UIPickerView
1.去掉分隔线,背景: 去掉分隔线: tableView.separatorStyle=UITableViewCellSeparatorStyleNone; //在syle为UITableViewStylePlain有效,隐藏了分隔线,但在UITableViewStyle为UITableViewStyleGrouped时不起作用. 或者用tableView.separa转载 2012-05-22 16:24:04 · 487 阅读 · 0 评论