`

iPhone开发笔记

 
阅读更多

退回输入键盘:


  - (BOOL) textFieldShouldReturn:(id)textField{

    [textField  resignFirstResponder];

}

 

CGRect

CGRect frame = CGRectMake (origin.x, origin.y, size.width, size.height);矩形

NSStringFromCGRect(someCG) 把CGRect结构转变为格式化字符串;

CGRectFromString(aString) 由字符串恢复出矩形;

CGRectInset(aRect) 创建较小或较大的矩形(中心点相同),+较小  -较大

CGRectIntersectsRect(rect1, rect2) 判断两矩形是否交叉,是否重叠

CGRectZero 高度和宽度为零的/位于(0,0)的矩形常量

 

CGPoint & CGSize

CGPoint aPoint = CGPointMake(x, y);    CGSize aSize = CGSizeMake(width, height);

 

设置透明度 [myView setAlpha:value];   (0.0 < value < 1.0)

设置背景色 [myView setBackgroundColor:[UIColor redColor]]; 

   (blackColor;darkGrayColor;lightGrayColor;whiteColor;grayColorredColorgreenColorblueColorcyanColor;yellowColor;magentaColor;

orangeColor;purpleColor;brownColor; clearColor; )

自定义颜色:

UIColor *newColor = [[UIColor alloc] initWithRed:(float) green:(float) blue:(float) alpha:(float)];      0.0~1.0

 

 

 

   320X480     480X320    状态栏高 20 像素高   导航栏 工具栏 44像素高

隐藏状态栏:

[[UIApplication shareApplication] setStatusBarHidden: YES animated:NO]

 

横屏:

[[UIApplication shareApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight].

orientation == UIInterfaceOrientationLandscapeLeft

window=[[UIWindow alloc] initWithFrame:[UIScreen mainScreen] bounds];全屏

 

自动适应父视图大小:

aView.autoresizingSubviews = YES;

aView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);

 

 定义按钮

UIButton *scaleUpButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];

[scaleUpButton setTitle:@" " forState:UIControlStateNormal];

scaleUpButton.frame = CGRectMake(4042010040);

[scaleUpButton addTarget:self action:@selector(scaleUpforControlEvents:UIControlEventTouchUpInside];

 

设置视图背景图片

UIImageView *aView;

[aView setImage:[UIImage imageNamed:@”name.png”]];

view1.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image1.png"]];

 

UISlider *slider = (UISlider *) sender;

NSString *newText = [[NSString alloc] initWithFormat:@”%d”, (int)(slider.value + 0.5f)];

label.text = newText;

 

活动表单 <UIActionSheetDelegate>


 - (IBActive) someButtonPressed:(id) sender

{

    UIActionSheet *actionSheet = [[UIActionSheet alloc] 

                    initWithTitle:@”Are you sure?”

                    delegate:self

                    cancelButtonTitle:@”No way!”

                    destructiveButtonTitle:@”Yes, I’m Sure!”

                    otherButtonTitles:nil];

    [actionSheet showInView:self.view];

    [actionSheet release];

}

 

警告视图  <UIAlertViewDelegate>


 - (void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex

{

     if(buttonIndex != [actionSheet cancelButtonIndex])

     {

          NSString *message = [[NSString alloc] initWithFormat:@”You can          

                   breathe easy, everything went OK.”];

          UIAlertView *alert = [[UIAlertView alloc]    

                               initWithTitle:@”Something was done”

                                message:message

                                delegate:self

                                cancelButtonTitle:@”OK”

                                otherButtonTitles:nil];

          [alert show];

          [alert release];

          [message release];

     }

}

 

动画效果

-(void)doChange:(id)sender

{

if(view2 == nil)

{

[self loadSec];

}

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1];        

[UIView setAnimationTransition:([view1 superview]?UIViewAnimationTransitionFlipFromLeft:UIViewAnimationTransitionFlipFromRight)forView:self.view cache:YES];

   

    if([view1 superview]!= nil)

{

[view1 removeFromSuperview];

[self.view addSubview:view2];

}else {

[view2 removeFromSuperview];

[self.view addSubview:view1];

}

[UIView commitAnimations];

}

分享到:
评论

相关推荐

    iphone开发笔记

    退回输入键盘 2 CGRect 2 CGPoint & CGSize 3 设置透明度 3 设置背景色 3 自定义颜色 3 竖屏 3 横屏 3 状态栏高 3 导航栏、工具栏高 3 隐藏状态栏 3 ...iPhone游戏中既播放背景音乐又...iphone更改键盘右下角按键的type 45

    iPhone 开发笔记实录(代码讲解)

    收集了IOS开发过程中常见的错误和需要注意的要点。

    iphone开发资料

    iphone开发笔记.iphone开发笔记.iphone开发笔记.iphone开发笔记.

    iphone开发学习笔记(1)--NSLog

    iphone开发学习笔记(1)--NSLog

    iPhone开发基础教程_学习笔记

    iPhone开发基础教程_学习笔记.docx

    IPhone开发常用技术笔记汇总

    本压缩包中包含了Iphone开发中常用到的技术总结笔记,五六十中技术方法以及季节方案,包括内存管理,方法回调,获取当前地点,自定义CELL,VIew圆角等等等,太多的奶水包,是我开发中所有的精华所在,只有你不知道的...

    iPhone笔记-Object-c基础

    iPhone笔记-Object-c基础总结

    iphone开发一年的工作笔记

    这份文档是我从事ios开发一年以来,总结工作中常用到的200余个ios小知识点,并添加可以调试观看的实例代码,方便iso开发者学习和交流,弄清楚这些,基本从事ios开发没什么问题。

    iphone笔记

    开发笔记,ios中关于入口类的相关方法的阐述,清晰的通俗

    移动互联网开发笔记 VOL 2

    刊首语 征稿 在Android平台下定制系统的主屏幕 IPhone开发内存管理  Three20的使用 iOS开发者计划申请流程攻略 雅虎画报IPad版本的开发经验介绍

    Iphone开发资料整理

    Cocoa基本原理指南.pdf Dashcode_UserGuide.pdf iPhonei&Touch.doc Objective-C Beginner's Guide.pdf

    iPhoneX安全区域与H5引发的问题(Safe Area)

    最近正在开发小程序相关的需求时,遇到了一个问题——ios高版本的安全区域,即iPhoneX及以上拥有的“刘海儿”等可滑动区域会与你开发的内容重合。 幸运的是,在小程序上我们只需要考虑底部的底部Home Indicator上滑...

    千锋OC源码,自学iphone开发

    千锋3g培训 OC源码以及课堂笔记 按日期分类 每天代码都有

    swift_study:详细信息!Swift iPhone App 开发入门笔记

    swift_study详细信息!Swift iPhone App 开发入门注的示例代码用于学习 Swift 开发

    IOS开发 初级笔记

    ios开发的一些经验 和一些很使用的快捷键 适合初学者

    timenote时光笔记(记事本软件) v2.37.zip

    TimeNote为珍惜时间,珍惜往事的人潜心开发的软件,一款具有独立文件与事件预测的跨平台日程管理软件(支持Android、IPhone与各PC平台)。本软件采用独家原创数据解码格式,支持云端异步操作,并能对普遍使用的ICS文件...

    objective c学习笔记和示例

    苹果的iPhone和iPad应用开发都指定使用同一开发语言:Objective-C语言。这是一种简单的面向对象编程语言,它的基础是C程序设计语言。Objective-C不仅功能强大,而且简单易学。Objective-C已经成为苹果系统下应用程序...

    fruitstrap:从命令行安装和调试iPhone应用程序,而无需使用Xcode

    您需要安装有效的iPhone开发证书。 必须安装Xcode以及适用于iOS版本的SDK。 用法 fruitstrap [-d] -b &lt;app&gt; [device_id] 安装应用程序后,可选的-d标志将启动远程GDB会话。 必须是iPhone应用程序捆绑包,而不是...

Global site tag (gtag.js) - Google Analytics