iPhone开发笔记 退回输入键盘:自定义颜色:隐藏状态栏:

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];
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值