如何以编程方式创建进度条?

发布于 2024-09-16 16:14:31 字数 88 浏览 2 评论 0原文

我使用 IBOutlet 创建了一个带有进度条的视图。每当我将视图旋转到横向模式时,它都不会旋转。因此,我需要以编程方式创建进度条。

我该怎么做?

I created a view with a progress bar with an IBOutlet. Whenever I rotate the view to landscape mode, it is not rotated. So, I need to create the progress bar programmatically.

How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

狠疯拽 2024-09-23 16:14:31
UIProgressView *progressView = [[UIProgressView alloc] init];
progressView.frame = CGRectMake(100,100,100,20);
[self.view addSubview:progressView];

应该让你开始。

我会阅读苹果文档中有关视图和视图控制器的内容。 iPhone OS 的 View 编程指南针对您想要执行的操作提供了相当多的细节。如果您还没有阅读 iPhone 应用程序编程指南和 iPhone 开发指南,我会先阅读。

所有这些文档都可以在developer.apple.com 上以及Xcode 的帮助系统中找到。

UIProgressView *progressView = [[UIProgressView alloc] init];
progressView.frame = CGRectMake(100,100,100,20);
[self.view addSubview:progressView];

Should get you started.

I would read up on views and view controllers in Apple's documentation. The View Programming Guide for iPhone OS goes into quite a bit of detail for what you want to do. If you have not read the iPhone Application Programming Guide and the iPhone Development Guide I would do so first.

All of these documents are available on developer.apple.com, and also in the help system of Xcode.

近箐 2024-09-23 16:14:31

您可以通过以下代码将进度条旋转为垂直:

progressView.transform= CGAffineTransformMakeRotation( M_PI * 0.5 );

You can rotate the progress bar to vertical by the below code:

progressView.transform= CGAffineTransformMakeRotation( M_PI * 0.5 );

夜未央樱花落 2024-09-23 16:14:31

您必须在 IB 中设置 size 属性,然后才能正常工作,请参见下图alt text

这对两者都适用方向

you have to set the property of size in IB then is't work fine see in below imagealt text

this work for both orientations

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文