alt text http://28.media.tumblr.com/tumblr_ky3ezghsar1qzzxzzo1_400.jpgUIActivityIndicatorView或者其他類似
誰能告訴我如何實現這樣的加載消息?它是UIActivityIndicatorView的一些變體嗎? 謝謝 彼得
alt text http://28.media.tumblr.com/tumblr_ky3ezghsar1qzzxzzo1_400.jpgUIActivityIndicatorView或者其他類似
誰能告訴我如何實現這樣的加載消息?它是UIActivityIndicatorView的一些變體嗎? 謝謝 彼得
旋轉輪絕對是一個UIActivityIndicatorView。 「加載...」文本是一個UILabel,矩形可以是一個圖像或者可以是一個圓角的UIView(通過CALayer)。有關郵件其餘部分的任何問題? T
如果您正在尋找現有的解決方案,您可以使用three20庫 - 它們已在TTActivityLabel
類中實現此功能。
類似的東西在你的自定義子類的UIView initWithFrame如下:
_hudView = [[UIView alloc] initWithFrame:CGRectMake(75, 155, 170, 170)];
_hudView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
_hudView.clipsToBounds = YES;
_hudView.layer.cornerRadius = 10.0;
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_activityIndicatorView.frame = CGRectMake(65, 40, _activityIndicatorView.bounds.size.width, _activityIndicatorView.bounds.size.height);
[_hudView addSubview:_activityIndicatorView];
[_activityIndicatorView startAnimating];
_captionLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 115, 130, 22)];
_captionLabel.backgroundColor = [UIColor clearColor];
_captionLabel.textColor = [UIColor whiteColor];
_captionLabel.adjustsFontSizeToFitWidth = YES;
_captionLabel.textAlignment = NSTextAlignmentCenter;
_captionLabel.text = @"Loading...";
[_hudView addSubview:_captionLabel];
[self addSubview:_hudView];
太棒了!感謝您的解決方案! – 2011-01-22 04:49:04
我做的方式這個作品更簡單流暢的我;
設計裏面你「的MainWindow.xib」 它可全部通過應用 的壽命在Interface Builder您加載視圖(當然,如果你有一個,根據類型和選擇的結構) 如果您沒有一個,只是在一些視圖中設計它,你可以以編程方式從你的主AppDelegate中獲取一個指針(使用你的設計選擇的味道,但使用MainWindow.xib是最簡單的)
然後將此視圖映射到您的YourApp類是您的臭名昭着的應用程序委託類。
Let the designed View map to an IBOutlet named "loading"
inside your app delegate class "YourApp"
by using the Interface Builder's wiring
然後,把下面的功能在一些班級,享受他們
此爲您展示運行一些昂貴的東西之前加載圖。
+(void)showLoading {
YourApp* app = (YourApp*)[[UIApplication sharedApplication] delegate];
[UIApplication sharedApplication].networkActivityIndicatorVisible = true;
[app.loading removeFromSuperview];
[app.window addSubview:app.loading];
app.loading.alpha = 0.0;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.50];
app.loading.alpha = 0.8;
[UIView commitAnimations];
}
並將其從回調中移除或者在昂貴的操作完成時將其移除;
+(void)hideLoading {
[UIApplication sharedApplication].networkActivityIndicatorVisible = false;
YourApp* app = (YourApp*)[[UIApplication sharedApplication] delegate];
[app.loading removeFromSuperview];
}
PS:是的,我使用NULL,真,假的不是零,YES,NO出於顯而易見的原因...
希望它能幫助, 享受...
看到這----
- (void)viewDidLoad {
[super viewDidLoad];
// [self ShowMsg];
//-----------------checking version of IOS -----------------------------------
CGFloat ver = [[[UIDevice currentDevice]systemVersion]floatValue];
NSString *str = [NSString stringWithFormat:@"%f",ver];
NSLog(@"%@",str);
NSArray *arr = [str componentsSeparatedByString:@"."];
strVerChk = [arr objectAtIndex:0];
NSLog(@"%@",strVerChk);
[strVerChk retain];
NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue];
NSLog(@"integer %d",verChk);
if (verChk < 5) {
imag = [UIImage imageNamed:@"WaitScreen.png"];
}
else
{
imag = [UIImage imageNamed:@"WaitScreen_5.png"];
}
Lblmsg = [[UILabel alloc]init];
//WithFrame:CGRectMake(10, 10, 100, 30)];
Lblmsg.backgroundColor = [UIColor clearColor];
Lblmsg.textColor = [UIColor whiteColor];
Lblmsg.text = @" Please Wait....";
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
[Lblmsg setFont:[UIFont fontWithName:@"Arial" size:16]];
}else
{
[Lblmsg setFont:[UIFont fontWithName:@"Arial" size:12]];
}
Lblmsg.textAlignment = UITextAlignmentCenter;
activityInd = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// [activityInd startAnimating];
imageview = [[UIImageView alloc]initWithImage:imag];
[imageview addSubview:Lblmsg];
[imageview addSubview:activityInd];
[self.view addSubview:imageview];
self.view.backgroundColor = [UIColor clearColor];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
// self.interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationPortrait ||orientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view.frame = CGRectMake(0, 0, 320, 480);
imageview.frame = CGRectMake(100, 130, 120, 80);
}
else{
self.view.frame = CGRectMake(0, 0, 480, 320);
imageview.frame = CGRectMake(180, 70, 120, 80);
}
Lblmsg.frame = CGRectMake(0, 45, 120, 40);
NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue];
NSLog(@"integer %d",verChk);
if (verChk < 5) {
activityInd.frame = CGRectMake(41, 9, 28, 28);
}
else
{
activityInd.frame = CGRectMake(41, 9, 28, 28);
}
[activityInd startAnimating];
}
else{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationPortrait ||orientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view.frame = CGRectMake(0, 0, 768, 1024);
imageview.frame = CGRectMake(274, 330, 210, 160);
Lblmsg.frame = CGRectMake(10, 115, 190, 30);
NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue];
NSLog(@"integer %d",verChk);
if (verChk < 5) {
activityInd.frame = CGRectMake(71, 20, 52, 52);
}
else
{
activityInd.frame = CGRectMake(71, 20, 49, 49);
}
[activityInd startAnimating];
}
else{
self.view.frame = CGRectMake(0, 0, 1024, 768);
imageview.frame = CGRectMake(390, 264, 200, 150);
Lblmsg.frame = CGRectMake(10, 115, 180, 30);
NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue];
NSLog(@"integer %d",verChk);
if (verChk < 5) {
activityInd.frame = CGRectMake(68, 17, 52, 52);
}
else
{
activityInd.frame = CGRectMake(68, 17, 49, 49);
}
[activityInd startAnimating];
}
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
}
-(void)didRotate{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
// self.interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationPortrait ||orientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view.frame = CGRectMake(0, 0, 320, 480);
imageview.frame = CGRectMake(100, 130, 120, 80);
//Lblmsg.frame = CGRectMake(0, 40, 120, 30);
//activityInd.frame = CGRectMake(20, 10, 80, 30);
}
else{
self.view.frame = CGRectMake(0, 0, 480, 320);
imageview.frame = CGRectMake(180, 70, 120, 80);
//activityInd.frame = CGRectMake(20, 10, 80, 30);
//activityInd.frame = CGRectMake(50, 15, 10, 10);
//[activityInd startAnimating];
}
Lblmsg.frame = CGRectMake(0, 45, 120, 40);
NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue];
NSLog(@"integer %d",verChk);
if (verChk < 5) {
activityInd.frame = CGRectMake(41, 9, 28, 28);
}
else
{
activityInd.frame = CGRectMake(41, 9, 28, 28);
}
[activityInd startAnimating];
}
else{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationPortrait ||orientation == UIInterfaceOrientationPortraitUpsideDown)
{
self.view.frame = CGRectMake(0, 0, 768, 1024);
imageview.frame = CGRectMake(274, 330, 210, 160);
Lblmsg.frame = CGRectMake(10, 115, 190, 30);
NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue];
NSLog(@"integer %d",verChk);
if (verChk < 5) {
activityInd.frame = CGRectMake(71, 20, 52, 52);
}
else
{
activityInd.frame = CGRectMake(71, 20, 49, 49);
}
[activityInd startAnimating];
}
else{
self.view.frame = CGRectMake(0, 0, 1024, 768);
imageview.frame = CGRectMake(390, 264, 200, 150);
Lblmsg.frame = CGRectMake(10, 115, 180, 30);
NSInteger verChk = [[NSString stringWithFormat:@"%@",strVerChk]intValue];
NSLog(@"integer %d",verChk);
if (verChk < 5) {
activityInd.frame = CGRectMake(68, 17, 52, 52);
}
else
{
activityInd.frame = CGRectMake(68, 17, 49, 49);
}
[activityInd startAnimating];
}
}
}
thanx你救了我的一天。 – 2011-12-12 04:35:19
如果你想要一個不同的動畫,我創建了一個自定義的UIView(Loader Animation)到你可以加載到的UIActivity
一個子類。
什麼配色方案... – kennytm 2010-02-25 07:59:52