When I set the anchor point, my image is not loading
I have a UIView on which i am loading my image view as a sub view. The image is showing when i doesn't set the anchor point but whenever i set anchor point the image is not showing .I have added the QUARTZCore frame work also.
I am adding my code below
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 = Y开发者_运维技巧ES;
handleView1.layer.anchorPoint=CGPointMake(490.0, 172.0);
[containerView addSubview:handleView1];
The problem are the values you use for the anchorPoint. You don't set points like for the position of a frame as values. Let me quote Apple:
The anchorPoint property is a CGPoint that specifies a location within the bounds of a layer that corresponds with the position coordinate. The anchor point specifies how the bounds are positioned relative to the position property, as well as serving as the point that transforms are applied around. It is expressed in the unit coordinate system-the (0.0,0.0) value is located closest to the layer’s origin and (1.0,1.0) is located in the opposite corner.
Have a look at Layer Geometry and Transforms in the Core Animation Programming Guide for more details.
First set the Frame of your ImageView and then set the ancherpoint like this
[ handleView1.layer setAnchorPoint:CGPointMake(1, 1)];
精彩评论