1. NSString *title = [sendertitleForState:UIControlStateNormal];
//根据sender的状态得到sender的title
2. isEqualToString:(NSString *)
//NSString类的方法, 比较字符串是否相等
3. _imageView.animationImages = [NSArrayarrayWithObjects:image1, image2, image3, image4,nil];//把image1-4 加入到图片动画数组中
_imageView.animationDuration =2.0;//动画间隔 2.0
[_imageViewstartAnimating];// 执行动画
//最终效果是UIImageView中,四张图片以动画形式播放
4. NSString *homeDir = NSHomeDirectroy() //获取沙盒目录路径函数。
/*获取Documents目录路径*/
NSArry *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *docDir = [pathsobjectAtIndex:0];
/*获取Caches目录路径*/
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES);
NSString *docDir = [pathsobjectAtIndex:0];
/*获取tmp目录路径*/
NSString *tmpDir =NSTemporaryDirectory();
————————————————————————————————————————————————————————————————————
5.
导航控制器可以用几种不同的风格来显示自身。默认风格就是标准的灰色外观。目前支持三种不同的风格。
风 格 |
描 述 |
UIBarStyleDefault |
默认风格;灰色背景,白色文字 |
UIBarStyleBlack |
纯黑色背景,白色文字 |
UIBarStyleBlackOpaque |
纯黑色背景,白色文字 |
UIBarStyleBlackTranslucent |
透明黑色背景,白色文字 |
风格是通过barStyle属性来设置的。这个属性属于导航控制器,而不是视图控制器,因此在各个视图之间来回切换时,此属性可以保持一致:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
6.
/*把searchbar里的textfield点击后弹出的键盘的确认键改为搜索二字*/
for (id subViewin _MysearchBar.subviews) {
if ([subViewisKindOfClass:[UITextFieldclass]]) {
/*点击textfield后弹出的键盘的确认键改为搜索二字*/
[(UITextField*)subViewsetReturnKeyType:UIReturnKeySearch];
}
}
7.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touchesanyObject ];
if (touch.tapCount ==2) {
/*取消之前的延时预处理*/
[[selfclass]cancelPreviousPerformRequestsWithTarget:selfselector:@selector(setBackgroundRed)object:nil];
[selfsetBackgroundBlue];
}
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touchesanyObject];
if (touch.tapCount ==1) {
/*延时预处理,0.3秒后,执行setBackgroundRed方法*/
[self performSelector:@selector(setBackgroundRed)withObject:nilafterDelay:0.3];
}
}
8.
返回的image是当前view的内容,类似做了张截图
必須先import QuzrtzCore.framework
-(UIImage*)captureView:(UIView *)theView
{
CGRect rect = theView.frame;
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[theView.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//UIImageWriteToSavedPhotosAlbum(image, self, nil, nil); //保存图片到相册
return img;