![](/img/trans.png)
[英]UIView is a child of UIScrollview, but when I zoom in or out the UIView doesn't stay in the correct location relative to the image in the scrollview
[英]Zoom effect in a UIView image
當用戶將鼠標懸停在圖像上時,點擊某個身體部位會顯示該區域的放大圖像。 我想知道任何可能的第三方框架,它們可以幫助我實現這一功能,可以解決此類功能或代碼片段(例如使用哪種手勢識別器)。
問題2:此外,我必須在觸摸發生和結束的位置添加動態可點擊標簽(因為您可以在圖像中看到手腕標簽),這樣我就可以在點擊標簽時將用戶帶到此屏幕的單獨視圖。 如何使這成為可能?
在drawRect方法中,屏蔽圓形(使用包含放大鏡“遮罩”的單色位圖)並使用2x縮放變換在其中繪制主題視圖。 然后在上面畫一個放大鏡圖像,你就完成了。
- (void) drawRect: (CGRect) rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect bounds = self.bounds;
CGImageRef mask = [UIImage imageNamed: @"loupeMask"].CGImage;
UIImage *glass = [UIImage imageNamed: @"loupeImage"];
CGContextSaveGState(context);
CGContextClipToMask(context, bounds, mask);
CGContextFillRect(context, bounds);
CGContextScaleCTM(context, 2.0, 2.0);
//draw your subject view here
CGContextRestoreGState(context);
[glass drawInRect: bounds];
}
請查看此鏈接以獲取完整示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.