你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS 實現簡單的移動UIView代碼實例

iOS 實現簡單的移動UIView代碼實例

編輯:IOS開發綜合
iOS 實現簡單的移動UIView代碼實例
在iewDidLoadzh中創建UIView
 [cpp]
UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(30.0, 30.0, 45.0, 45.0)]; 
    tmpView.backgroundColor = [UIColor brownColor]; 
    tmpView.tag = 100; 
    [self.view addSubview:tmpView]; 
     
    [tmpView release]; 
實現簡單的移動UIView
[cpp] 
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 

    UITouch *touch = [touches anyObject]; 
    UIView *viewDemo = (UIView*)[self.view  viewWithTag:100]; 
    CGPoint point = [touch  locationInView:self.view]; 
    CGRect  frame = viewDemo.frame; 
    frame.origin = point; 
    viewDemo.frame = frame; 
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved