CGRect rectSearchLocationFrame=self.rectsearchLocation;
CGRect rectSearchCityFrame = self.rectsearchCity;
rectSearchLocationFrame.size.width += change *changeByMuch;
rectSearchCityFrame.size.width -= change * changeByMuch;
rectSearchCityFrame.origin.x +=change*changeByMuch;
self.searchLocation.frame = rectSearchLocationFrame;
self.searchCity.frame = rectSearchCityFrame;
PO1(self.searchLocation.textField);
PO1(self.searchCity.textField);
//NSAssert(false, @"Hello");
我仔細看。 self.searchLocation的確有變化框架爲什麼更改UISearchBar的框架根本不起作用
(lldb) po self.searchLocation
<BGSearchBar: 0x158e5130; baseClass = UISearchBar; frame = (0 38; 260 44); text = ''; opaque = NO; autoresize = W+BM; gestureRecognizers = <NSArray: 0x158d1ba0>; layer = <CALayer: 0x158e5220>>
你看,框架?那裏的寬度是260,而不是160.它不應該在中間結束。
然而,這是截圖
如果我動畫的運動,似乎它實際上改變大小。然而,它慢慢迴歸。有些東西可以回到原來的大小。
我得到這個錯誤:
invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
你在你的筆尖中使用了自動佈局嗎?試試self.searchbar.translatesAutoresizingMaskIntoConstraints =否如果是的話。 –
嘗試記錄'rectSearchLocationFrame'而不是視圖幀請注意'frame'屬性是動畫的,所以它不必在改變後不久顯示當前的大小。 – Sulthan