你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS編程技術 >> iOS小技巧之透明鍵盤等

iOS小技巧之透明鍵盤等

編輯:IOS編程技術
鍵盤透明:  

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 = UIImagePNGR epresentation(aImage); 
更改cell選中的背景: 

UIView *myview = [[UIView alloc] init]; 
   myview.frame = CGRectMake(0, 0, 320, 47); 
   myview.backgroundColor = [UIColorcolorWithPatternImage:[UIImage imageNamed:@"0006.png"]]; 
   cell.selectedBackgroundView = myview;
.顯示圖片:

CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f, 109.0f);  
UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; 
[myImage setImage:[UIImage imageNamed:@"myImage.png"]];  
myImage.opaque = YES; //opaque 是否透明 
[self.view addSubview:myImage];
能讓圖片適應框的大小(beta)
 
NSString*imagePath = [[NSBundle mainBundle] pathForResource:@"XcodeCrash"ofType:@"png"];      
    UIImage *image = [[UIImage alloc]initWithContentsOfFile:imagePath];  
        UIImage *newImage= [image transformWidth:80.f height:240.f];  
    UIImageView *imageView = [[UIImageView alloc]initWithImage: newImage];  
         [newImagerelease];  
    [image release];  
    [self.view addSubview:imageView];
  實現點擊圖片進行跳轉的代碼:(生成一個帶有背景圖片的button,給button綁定想要的事件)

UIButton *imgButton=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 120, 120)];  
[imgButton setBackgroundImage:(UIImage *)[self.imgArray objectAtIndex:indexPath.row] forState:UIControlStateNormal];  
imgButton.tag=[indexPath row];  
[imgButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];  
.第二種方法:在背景圖片上添加Tap事件,相應單擊處理。這種方法,很好代替了button方式,但是如果UI上沒有背景圖片,這種方法又回到到第一種山寨的方法行列中。

// 添加帶有處理時間的背景圖片 

UIImageView *backView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];  
 
    backView.image = [UIImage imageNamed:@"small3.png"];  
 
      
 
    backView.userInteractionEnabled = YES;  
 
    UITapGestureRecognizer *singleTouch = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard:)];  
 
    [backView addGestureRecognizer:singleTouch];  
 
      
 
    backView.tag = 110;  
 
    [self.view addSubview:backView];  
 
 
 
-(void)dismissKeyboard:(id)sender{  
 
    [text resignFirstResponder];  
 
}  
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved