4
在我的iOS應用程序中,我有一個UIToolbar控件的媒體播放器。我想讓UIBarButtonItem從左側滑入UIToolbar,就像我在播放器屏幕上觸摸一樣。如何使UIBarButtonItem在左側的UIToolbar上滑動?
這是我試過的,它確實從左邊添加了UIBarButtonItem,但沒有動畫部分。
// create new button
UIBarButtonItem* b = [[UIBarButtonItem alloc] initWithTitle:@"b"
style:UIBarButtonItemStyleBordered
target:self
action:nil];
NSMutableArray* temp = [toolbar.items mutableCopy]; // store the items from UIToolbar
NSMutableArray* newItems = [NSMutableArray arrayWithObject:b]; // add button to be on the left
[newItems addObjectsFromArray:temp]; // add the "old" items
[toolbar setItems:newItems animated:YES];
任何形式的幫助,高度讚賞!
謝謝!這是一個非常好的方法!我以類似的方式解決了這個問題。但是,我殺死了UIToolbar並在其上創建了自己的帶有UIButton的自定義工具欄... –