自定义UIActivityIndi​​cator,它是自定义框架的一部分或作为子类 [英] Custom UIActivityIndicator, that is part of customized Framework or as a Sub Class

查看:101
本文介绍了自定义UIActivityIndi​​cator,它是自定义框架的一部分或作为子类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找有关创建自定义UIActivityIndi​​cator的最佳方法的一些帮助。我认为理想情况下,它应该是UIActivityIndi​​cator的SubClass,以便我们可以轻松地将其分发给可能想要利用它的其他应用程序,并轻松拖放到Interface Builder中的应用位置。

Looking for some help on the best way to create a custom UIActivityIndicator. I think that ideally, it should be a SubClass of UIActivityIndicator so that we can easily distribute it to other apps that might want to take advantage of it, and easily drag and drop where it should go in Interface Builder.

作为一个例子,TMZ应用程序上的UIActivityIndi​​cator似乎是自定义的,但是对于Objective-C和Xcode开发是新手,我正在努力争取一个地方开始和最有效的方法。这个众所周知的轮子是否已经创建?

As an example, the UIActivityIndicator on the TMZ app seems to be custom, but being new to Objective-C and over Xcode development, and I'm struggling with a place to start and the best most efficient approach. Has this proverbial "wheel" already been created?

提前感谢您的时间。

推荐答案

UIActivityIndi​​cator不是为了自定义而设计的,所以对它进行子类化对你来说不会太好。但它是一个简单的UI元素,可以在一小时内从头开始编写。由于您不希望它响应事件,因此将其作为UIView的子类并将 userInteractionEnabled 设置为NO。缺点是IB不会像UIActivityIndi​​cator那样显示出良好的预览。

UIActivityIndicator is not designed to be customized, so subclassing it won't do you much good. But it is a simple UI element which can be written from scratch in an hour. Since you don't want it to respond to events, make it a subclass of UIView and set userInteractionEnabled to NO. The downside is that IB won't show a nice preview as with UIActivityIndicator.

重用这样的类很简单:只需将接口/实现文件添加到Xcode项目中即可#import标题。

Reusing such a class is easy: just add the interface/implementation files to an Xcode project and #import the header.

UIActivityIndi​​cator的工作方式类似于动画GIF,显示一系列图像。当然,您也可以这样做,或者您只需为子图层的转换属性设置动画即可使其旋转。

UIActivityIndicator works like an animated GIF, displaying a series of images. Of course, you can do the same or you can just animate transform property of a sublayer to make it spin.

这篇关于自定义UIActivityIndi​​cator,它是自定义框架的一部分或作为子类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆