I have a custom UIImageView where i am placing a UILabel in the init method:
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.displayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, (self.frame.size.width - 14), (self.frame.size.height - 14))];
self.displayNameLabel.center = CGPointMake((self.frame.size.width / 2), (self.frame.size.height / 2));
self.displayNameLabel.backgroundColor = [UIColor clearColor];
self.displayNameLabel.textAlignment = UITextAlignmentCenter;
self.displayNameLabel.font = [UIFont fontWithName:labelFont size:22];
[self addSubview:self.displayNameLabel];
// Other code
}
}
this is placed in another UIImageView which is in a UIScrollView.
so, UIScrollView which contains UIImageView which contains custom UIImageView which contains UILabel
when i zoom in on the UIScrollView, my label gets all goofy.
how it looks with no zoom:
after zooming in:
I do resize the custom UIImageView when i zoom in so it keeps a constant size (doesn't get larger as you zoom in):
-(void)scrollViewDidZoom:(UIScrollView *)scrollView
{
for (PointImageView *point in self.mapImageView.subviews)
{
if ([point isKindOfClass:[PointImageView class]])
{
CGPoint oldCenter = point.center;
float pointSize = point.frame.size.width;
float newPointSize = pointSize / zoomScale;
point.frame = CGRectMake(point.frame.origin.x, point.frame.origin.y, newPointSize, newPointSize);
point.center = oldCenter;
}
}
oldZoomScale = scrollView.zoomScale;
}
when i move my custom UIImageView, why doesn't the label move with it?