我正在创建一个应用程序,它应该在停靠图标中显示进度条。目前我有这个,但它不起作用:
NSProgressIndicator *progressIndicator = [[NSProgressIndicator alloc] initWithFrame:NSMakeRect(0.0f, 0.0f, 10.0f, 20.0f)];
[progressIndicator setStyle:NSProgressIndicatorBarStyle];
[progressIndicator setIndeterminate:NO];
[[[[NSApplication sharedApplication] dockTile] contentView] addSubview:progressIndicator];
[progressIndicator release];
还是我必须自己在码头上画它?谁能帮我?谢谢。
最后我不得不使用以下代码,因为 contentView 为空:
docTile = [[NSApplication sharedApplication] dockTile];
NSImageView *iv = [[NSImageView alloc] init];
[iv setImage:[[NSApplication sharedApplication] applicationIconImage]];
[docTile setContentView:iv];
progressIndicator = [[NSProgressIndicator alloc]
initWithFrame:NSMakeRect(0.0f, 0.0f, docTile.size.width, 10.)];
[progressIndicator setStyle:NSProgressIndicatorBarStyle];
[progressIndicator setIndeterminate:NO];
[iv addSubview:progressIndicator];
[progressIndicator setBezeled:YES];
[progressIndicator setMinValue:0];
[progressIndicator setMaxValue:1];
[progressIndicator release];
[self setProgress:[NSNumber numberWithFloat:-1]];
}
- (void)setProgress:(NSNumber *)fraction {
if ( [fraction doubleValue] >= 0 ) {
[progressIndicator setDoubleValue:[fraction doubleValue]];
[progressIndicator setHidden:NO];
}
else
[progressIndicator setHidden:YES];
[docTile display];
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)