怎样让外界无法改变自定义view的尺寸大小

 重写setFrame和setBounds方法即可。

+ (instancetype)testView
{
    return [[self alloc] init];
}

- (void)setFrame:(CGRect)frame
{
    frame.size = CGSizeMake(100, 100);
    [super setFrame:frame];
}

- (void)setBounds:(CGRect)bounds
{
    bounds.size = CGSizeMake(100, 100);
    [super setBounds:bounds];
}

 

posted @ 2015-06-01 18:54  Emyin  阅读(192)  评论(0编辑  收藏  举报