2011-05-11 37 views
5

我有一个UIView,我在其上加载我的图像视图作为子视图。当我没有设置锚点时,图像显示,但每当我设置锚点图像不显示。我也添加了QUARTZCore框架的工作。当我设置定位点时,我的图像不加载

我加入我的代码如下

CGRect apprect=CGRectMake(0, 0, 1024, 768); 
UIView *containerView = [[UIView alloc] initWithFrame:apprect1]; 
containerView.backgroundColor = [UIColor whiteColor]; 
[self.view addSubview:containerView]; 

handleView1= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"large.gif"]]; 
[handleView1 setAlpha:1]; 
//[handleView1 setFrame:CGRectMake(390, 172.00, 56.00, 316.00)]; 
handleView1.userInteractionEnabled = YES; 
handleView1.layer.anchorPoint=CGPointMake(490.0, 172.0); 
[containerView addSubview:handleView1]; 

回答

6

的问题是,你使用的anchorPoint值。您不会将帧的位置设置为值。让我引用苹果:

的anchorPoint属性是一个CGPoint 指定与位置坐标对应 层的 范围内的位置。定位点 指定界限 相对于位置属性 的位置以及如何应用 作为应用周围 转换的点。 单位坐标系 (0.0,0.0)的值位于最接近 图层的原点,并且(1.0,1.0)位于对角的 ,表示为 。

enter image description here

看一看Layer Geometry and Transforms in the Core Animation Programming Guide了解更多详情。

+0

非常感谢你尼克韦弗。非常感谢。 – Lena 2011-05-11 07:37:09

0

首先设置你的ImageView的框架,然后设置这样

的ancherpoint [handleView1.layer setAnchorPoint:CGPointMake(1,1)];

相关问题