1
iPad App에서 투명한 UIToolBar를 서브 클래 싱하여 만들려고합니다. 이 작업을 수행하는 방법에 대한 몇 가지 예를 보거나 읽었지만 내 코드는 제대로 보이지만 앱을 실행하면 배경이 투명하지 않고 검정색으로 변합니다.iPad 앱에서 UIToolBar를 서브 클래 싱하여 투명하게 만들면 검은 색으로 변합니다.
#import <UIKit/UIKit.h>
@interface TransparentToolBar : UIToolbar {
}
@end
그리고 지금 내하는 .m 파일 : 여기
내 TransparentToolBar.h 파일입니다#import "TransparentToolBar.h"
@implementation TransparentToolBar
// Override draw rect to avoid
// background coloring
- (void)drawRect:(CGRect)rect {
// do nothing in here
}
// Set properties to make background
// translucent.
- (void) applyTranslucentBackground
{
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
self.translucent = YES;
}
// Override init.
- (id) init
{
self = [super init];
[self applyTranslucentBackground];
return self;
}
- (id)initWithFrame:(CGRect)aRect {
if ((self = [super initWithFrame:aRect])) {
[self applyTranslucentBackground];
}
return self;
}
@end
그것은 초기화 기능과 같은 호출 받고되지 않지만의 drawRect 기능입니다 IB에서 설정 한 배경을 제거하기 때문입니다.
가 완벽하게 작동합니다! 고맙습니다! – AngeloS