leftBarButtonItem此保證金邏輯任何人都可以向我解釋在這個屏幕截圖下面看到的邊距是從哪裏來的?我希望紅色,綠色和藍色矩形在屏幕布局,風景和肖像中都能夠彼此相鄰。相反,我在這些觀點之間看到了莫名其妙的利潤。解釋爲leftBarButtonItem,rightBarButtonItem,titleView
// Setup Left Bar Button item
UIBlankToolbar* tools = [[[UIBlankToolbar alloc] initWithFrame:CGRectMake(0, 0, 115, 44)] autorelease];
tools.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[tools setBackgroundColor:[UIColor greenColor]];
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:tools] autorelease];
...
// Setup Right Bar Button Item
UIBlankToolbar* tools = [[[UIBlankToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 44)] autorelease];
[tools setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[tools setBackgroundColor:[UIColor redColor]];
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:tools] autorelease];
...
// Setup Title View
self.navigationItem.titleView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 44)] autorelease];
self.navigationItem.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[self.navigationItem.titleView setBackgroundColor:[UIColor blueColor]];
我看到這個代碼是什麼:
真正困擾我的是,觀點之間的利潤率空間變大可以變小?我不明白他們爲什麼在那裏,也不明白他們爲什麼會違揹我期望的利潤。
謝謝!
如果你不使用靈活的寬度會發生什麼? – 2011-05-27 22:58:33
如果我不使用柔性寬度,綠色塊保持其寬度相同,與左側對齊,藍色和紅色右對齊,綠色和藍色之間出現較大間隙。但是,這些差距的存在本身就是我不瞭解的。 – esilver 2011-05-28 20:12:14
嘿,順便說一下,蘋果文檔說,當leftBarButton項不爲零時,titleView將被忽略。你意識到這點了嗎?你有解決方法嗎? – kris 2011-10-11 19:34:44