uiactivityIndi​​catorView的背景图像

时间:2011-07-21 01:17:41

标签: iphone xcode android-activity uiactivityindicatorview

所以,我正在以编程方式创建activityIndi​​cator。一切正常。现在我想为指标添加背景图像并将其置于视图中间。知道如何实现这个目标吗?

这是我的代码:

- (void) indicatorViewShow: (bool)show {

    if (show) {
        //--- create layout rect
        CGRect indicatorRect;
        indicatorRect.origin = self.view.center;
        indicatorRect.size.width  = 50;
        indicatorRect.size.height = 50;

        indicatorRect.origin.x -= indicatorRect.size.width / 2;

        //--- create indicator view
        indicatorView = [[IndicatorView alloc] initWithFrame: indicatorRect];

        indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
        [indicatorView startAnimating];
        [self.view addSubview: indicatorView];

        //--- show network activity
        [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    } else {
        //--- hide network activity
        [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
        [indicatorView stopAnimating];
        //--- remove indicator view
        indicatorView.hidden = YES;
        [indicatorView release];
        indicatorView = nil;
    }

}

1 个答案:

答案 0 :(得分:0)

您可以继承UIActivityIndi​​cator,在该类中添加UIImageView,然后您有一个带有背景图像属性的活动指示器