2012-10-21 52 views
1

我正在爲iPad開發一個iOs應用程序,並在UIView內部實現了一個UIImageView。問題是,如果圖像視圖的位置超出UIView的位置,您可以看到它。代碼:UIImageView在其父母框外顯示

UIView *vistafunda = [[UIView alloc] initWithFrame:CGRectMake(512/2, 48, 525, 651)]; 
[self.view addSubview:vistafunda]; 
vistafunda.backgroundColor = [UIColor darkGrayColor]; 

UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hola.png"]]; 
img.center = CGPointMake(12, 200); 
[vistafunda addSubview:img]; 

我想圖像視圖總是在視圖下,所以如果圖像在視圖之外,你看不到它。 謝謝!

回答

8

只是使含視野片段是孩子

vistafunda.clipsToBounds = YES; 
+0

非常感謝,它完美!!!!! –