How to lock designable size of custom UView

I am making a custom activityIndicator. I wanted it to behave like UIActivityIndicatorView but with different animations.

When you place UIActivityIndicatorView to Storyboard the width and height of this view are locked for modification (grayed out).

There is no problem to make fixed width for the view in code but is it possible to make custom view the same way UIActivityIndicatorView is made: with width and height grayed out in storyboard?


Thorax, good day!

Well, i found an answer for your question here!

Though it was 1.5 year ago, i don't think that something had changed


I don't know how to grayed out width and height, but there is a way to avoid setting width and height constrains all the time in IB: you should just override intrinsicContentSize() in your UIView subclass. In Swift for example:

override func intrinsicContentSize() -> CGSize {
    return CGSizeMake(50, 50)
}
链接地址: http://www.djcxy.com/p/38368.html

上一篇: 打开文件夹中的所有文件并应用功能

下一篇: 如何锁定自定义UView的可设计大小