アプリをラップするために使用している UITabBar の高さ、幅、位置に合わせてローダー サブビューを初期化しています。
// In UITabBarController implementation
LoaderView *loaderView = [[LoaderView alloc] initWithFrame:[self tabBar].viewForBaselineLayout.frame];
[[self view] addSubview:loaderView];
//
// LoaderView.h
#import <UIKit/UIKit.h>
@interface LoaderView : UIView
@property (nonatomic, strong) UILabel *messageLabel;
@property (nonatomic, strong) NSString *message;
@property (nonatomic) CGRect frame;
- (void)createLabel;
- (void)drawLoader;
- (void)setText:(NSString *)newMessage;
- (void)show:(NSNotification *)notification;
@end
//
// LoaderView.m
#import "LoaderView.h"
@implementation LoaderView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self drawLoader];
}
return self;
}
- (void)drawLoader
{
UIColor *semiOpaqueGray = [[UIColor alloc] initWithRed:0.0f green:0.0f blue:0.0f alpha:0.8f];
[self setBackgroundColor:semiOpaqueGray];
[self createLabel];
}
- (void)createLabel
{
_messageLabel = [[UILabel alloc] initWithFrame: CGRectMake(15,9,([self frame].size.width - 10), 30)];
_messageLabel.textColor = [[UIColor alloc] initWithWhite:1.0 alpha:1];
_messageLabel.backgroundColor = [[UIColor alloc] initWithWhite:1.0 alpha:0.0];
[self addSubview:_messageLabel];
}
@end
構造体は、このframe
着信フレーム データを表します。
2013-09-16 07:48:35.552 ---[97825:a0b] {{0, 519}, {320, 49}}
// Ostensibly 0,519 origin point and 320,49 w/h
その結果がこれです。ほとんど不透明な暗いボックスが左上隅にあります。ローダーの中心点から画面の左上端に配置されているように見えます。
ボックスのサイズを変更できますが、左上の位置から移動できないようです。さらに、アニメーションを設定すると、そのアニメーションがフレームを調整します (タブ バー領域から上下にスライドさせます)。それも効果がないようです。
よろしくお願いします。