Anish Joseph
Anish Joseph

Reputation: 1026

Issue with image view orgin in ios

I am doing a module where there is a pin drop functionality. The pin[Image view] is dropped on a scroll view which is zoom-able. When zoomed the the image view moves in accordance with its center orgin.

I would like to make it moved with its bottom point.

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale;
{
    zoomLevel=scale;
    for (SSSmartPinView *smartPinView in smartPinViewMutArray) {
        smartPinView.zoomScale = zoomLevel;
        smartPinView.parrentOffset = drawingScrollView.contentOffset;
        smartPinView.center = CGPointMake(([smartPinView.coresmartPin.xpoint floatValue]*zoomLevel),(([smartPinView.coresmartPin.ypoint floatValue]+(zoomLevel))*zoomLevel));



    }


}
- (void)scrollViewDidZoom:(UIScrollView *)scrollView{
    zoomLevel=scrollView.zoomScale;
    for (SSSmartPinView *smartPinView in smartPinViewMutArray){
        smartPinView.zoomScale = zoomLevel;
        smartPinView.parrentOffset = drawingScrollView.contentOffset;

      smartPinView.center = CGPointMake(([smartPinView.coresmartPin.xpoint floatValue]*zoomLevel),(([smartPinView.coresmartPin.ypoint floatValue]+(zoomLevel))*zoomLevel));


    }
}

Upvotes: 0

Views: 79

Answers (1)

Turch
Turch

Reputation: 1546

You can set the anchor (center point for rotation / scaling) with

smartPinView.layer.anchorPoint = CGPointMake(0.5, 1.0);

See the anchorPoint property

Upvotes: 1

Related Questions