0

アプリをラップするために使用している 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

その結果がこれです。ほとんど不透明な暗いボックスが左上隅にあります。ローダーの中心点から画面の左上端に配置されているように見えます。

置き忘れた灰色のボックスのスクリーンショット

ボックスのサイズを変更できますが、左上の位置から移動できないようです。さらに、アニメーションを設定すると、そのアニメーションがフレームを調整します (タブ バー領域から上下にスライドさせます)。それも効果がないようです。

よろしくお願いします。

4

2 に答える 2

0

あなたのスーパービューが問題です。UINavigationController に追加している場合、y 軸は適切に応答しない可能性があります。コントローラーのプライマリ ビューを使用してみてください

loaderView.frame = CGRectMake(x, 514, 40, 320);  // made up numbers
[self.mapView addSubview:loaderView];

また、あなたはタブバーにアクセスしています。UIDevice ウィンドウを使用して幅を取得し、下部のラベルから高さを継承してみてください (または、LoaderView 内でラベルをネストします)。

また、これを処理するために実際に UITabBar を使用することも検討してください。

于 2013-09-20T06:12:37.103 に答える