我想在另一個視圖內有一個可移動/可縮放/可旋轉的視圖。內部視圖可以超出外部視圖的框架,但我想保留它的一部分在外部視圖內,所以內部視圖不會丟失。如何在另一個UIView中保留一個旋轉的UIView? (框架不能使用)
我簡化了這個xcode項目中的問題https://github.com/nextorlg/Intersection。
如果內部的觀點是唯一可移動的和可擴展的問題就已經解決了,但是當內部視圖旋轉,這種解決方案,因爲該框架包含了看法,但它是不是認爲自己這是不好的。
到我用這個功能來驗證新的視圖位置,如果它是無效的我回復最後轉換內部視圖執行的每個轉變(這是可移動的視圖代碼https://github.com/nextorlg/Intersection/blob/master/intersec/MovableView.m)
-(BOOL) validInset {
CGRect outerLimit = CGRectMake(0, 0, self.superview.frame.size.width, self.superview.frame.size.height);
CGRect intersectionRect = CGRectIntersection(self.frame, outerLimit);
NSLog(@"self.frame:%f,%f,%f,%f", self.frame.origin.x, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
NSLog(@"outer.frame:%f,%f,%f,%f", outerLimit.origin.x, outerLimit.origin.y, outerLimit.size.width, outerLimit.size.height);
NSLog(@"intersec.frame:%f,%f,%f,%f", intersectionRect.origin.x, intersectionRect.origin.y, intersectionRect.size.width, intersectionRect.size.height);
NSLog(@"========================");
if (CGRectIsNull(intersectionRect) ||
intersectionRect.size.width < INSET ||
intersectionRect.size.height < INSET) {
return NO;
}
else {
return YES;
}
}
問題是,我怎麼能確定它的內部視圖不會在第一次旋轉一些(例如45度)度並拖到角落時在外部視圖後面丟失?
一個評論,我想保持外觀圖裏面只是一些像素,因爲內部視圖可以比外一個更大的(按比例)。
我建議您下載並運行該項目,以更好地understan的問題,這是很難理解它只是閱讀本。
謝謝!
不太喜歡它,但工作... – Nextorlg