【问题标题】:When I set the anchor point, my image is not loading当我设置锚点时,我的图像没有加载
【发布时间】:2011-05-11 07:28:11
【问题描述】:

我有一个 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];

【问题讨论】:

    标签: objective-c ios ipad core-graphics


    【解决方案1】:

    问题在于您用于锚点的值。您不会像框架的位置那样将点设置为值。让我引用苹果的话:

    anchorPoint 属性是一个 CGPoint 指定在 对应的层的边界 与位置坐标。这 锚点指定边界如何 相对于 位置属性,以及服务 因为变换的点是 应用在周围。 表示为 单位坐标系-the (0.0,0.0) 值位于最接近 图层的原点和 (1.0,1.0) 是 位于对面的角落。

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

    【讨论】:

      【解决方案2】:

      首先设置你的ImageView的Frame,然后像这样设置ancherpoint

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

      【讨论】:

        猜你喜欢
        • 2013-01-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-07-13
        • 2018-11-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多