У меня проблема с установкой нового кадра для объекта uiview.вот мой код:
UIImageView *blockImage=[[UIImageView alloc] initWithFrame:CGRectMake(0, [y doubleValue], self.view.frame.size.width, 86)];
[blockImage setImage:[UIImage imageNamed:@"mainscreen_block_sample.jpg"]];
[blockImage setBackgroundColor:[UIColor blackColor]];
//setting anchor point
[blockImage.layer setAnchorPoint:CGPointMake(0.5, 1.0)];
//preparing transform
float distance = 500;
CATransform3D basicTrans = CATransform3DIdentity;
basicTrans.m34 = 1.0 / -distance;
//calculating angle
double OF=oldSize/2.0-difference;
double OC=oldSize/2.0;
double angle= acosf(OF/OC);
angle=angle/2.0;
//transforming
blockImage.layer.transform = CATransform3DRotate(basicTrans, angle, 1.0f, 0.0f, 0.0f);
double newOriginY=[y doubleValue]-difference;
double newFrameHeight=blockImage.frame.size.height;
[blockImage setFrame:CGRectMake(0, newOriginY, blockImage.frame.size.width, newFrameHeight)];
NSLog(@" blockImage frame y: %g", blockImage.frame.origin.y);
NSLog(@" blockImage frame height: %g", blockImage.frame.size.height);
//adding subview
[blocks addObject:blockImage];
[self.view addSubview:[blocks objectAtIndex:([blocks count]-1)]];
//releasing memory
[blockImage release];
Вывод NSLog нежелателен: (
значения нового прямоугольника: newOriginY: 78 newFrameHeight: 77.82
, но NSLog отличается:blockImage frame y: 85.0665 blockImage frame frame: 70.7535