Tôi muốn làm cho UIToolBar của tôi có nền trong suốt (tương tự như iBooks) nhưng tôi không có may mắn khi thiết lập thuộc tính translucent
.Làm thế nào để làm cho nền của UIToolbar trong suốt?
Dưới đây là mã của tôi:
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
NSMutableArray *toolBarItems = [[NSMutableArray alloc] init];
[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:nil action:nil]];
[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Source" style:UIBarButtonItemStyleBordered target:nil action:nil]];
[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Aa" style:UIBarButtonItemStyleBordered target:nil action:nil]];
[toolBarItems addObject:[[UIBarButtonItem alloc] initWithTitle:@"Rabbit" style:UIBarButtonItemStyleBordered target:nil action:nil]];
toolBar.items = toolBarItems;
toolBar.translucent = YES;
[self.view addSubview:toolBar];
Nó vẫn đi ra như thế này:
Tôi tin rằng bạn sẽ cần đặt hình nền trong suốt để thực hiện việc này. Chỉ cần tạo một pixel png trong suốt 1x1 pixel. – MTurner
@doug Smithh là uitoolbar là một phân lớp của uiview bạn có thể sử dụng thuộc tính lớp của nó để làm cho nó trong suốt bằng cách thay đổi giá trị alpha –
Hãy xem: http://stackoverflow.com/questions/2468831/couldnt-uitoolbar- minh bạch # answer-3253738 – Shad