以编程方式调整集合视图单元格中的元素大小

时间:2016-01-20 01:10:12

标签: ios iphone swift uicollectionviewcell nslayoutconstraint

我一直试图以编程方式调整集合视图单元格中图片视图的大小,我已经尝试过......

public class MyCbx : CheckBox {
    protected override void OnGotFocus(EventArgs e) {
        base.OnGotFocus(e);
        base.OnEnter(e);
        base.OnMouseEnter(e);
    }
    protected override void OnLostFocus(EventArgs e) {
        base.OnLostFocus(e);
        base.OnLeave(e);
        base.OnMouseLeave(e);
    }
    protected override void OnMouseLeave(EventArgs e) {
        if(!this.Focused) {//prevent it from losing highligh if control is in focus
            base.OnMouseLeave(e);
        }
    }
}

根本没有影响图像视图。我也尝试以编程方式添加约束...

override func awakeFromNib() {
    imageView.frame = CGRectMake(0,0,77,77)
}

我尝试将这些约束添加到awakeFromNib和cellForItem函数中,这个函数根本不会影响图像视图。如果需要更多信息,请告诉我。谢谢!

0 个答案:

没有答案