iphone开发者笔记

来源:互联网 发布:mac qq 截图录屏 失效 编辑:程序博客网 时间:2024/05/17 06:21
1.iphone之UISegmentedControl
代码:
//选择按钮
 
 NSArray*buttonNames = [NSArray arrayWithObjects:@"今天", @"本周", @"本月",nil];
 
 UISegmentedControl* segmentedControl = [[UISegmentedControl alloc]initWithItems:buttonNames];
 
 [segmentedControl setFrame:CGRectMake(60, 10, 200, 40)];
 
 segmentedControl.selectedSegmentIndex=1;
//添加事件
 
 [segmentedControl addTarget:self action:@selector(segmentAction:)forControlEvents:UIControlEventValueChanged];
 
 [self.viewaddSubview:segmentedControl];
 
 [segmentedControl release];
//事件
-(void)segmentAction:(UISegmentedControl *)Seg{

    
 NSIntegerIndex = Seg.selectedSegmentIndex;
 
 NSLog(@"Seg.selectedSegmentIndex:%d",Index);

}


2.键盘透明
textField.keyboardAppearance = UIKeyboardAppearanceAlert;

状态栏的网络活动风火轮是否旋转
[UIApplication sharedApplication].networkActivityIndicatorVisible,默认值是NO。

截取屏幕图片
//创建一个基于位图的图形上下文并指定大小为CGSizeMake(200,400)
UIGraphicsBeginImageContext(CGSizeMake(200,400)); 

//renderInContext 呈现接受者及其子范围到指定的上下文
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];

 //返回一个基于当前图形上下文的图片
 UIImage *aImage = UIGraphicsGetImageFromCurrentImageContext();

 //移除栈顶的基于当前位图的图形上下文
UIGraphicsEndImageContext();

//以png格式返回指定图片的数据
imageData = UIImagePNGRepresentation(aImage);

更改cell选中的背景
    UIView *myview = [[UIView alloc] init];
    myview.frame = CGRectMake(0, 0, 320, 47);
    myview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"0006.png"]];
    cell.selectedBackgroundView = myview; 

原创粉丝点击