减少UIView大小而不减少其内容

时间:2017-01-13 07:36:57

标签: ios objective-c swift uiview

我正在绘制UIView的框架属性(x,y,宽度,高度)值[0, 0, 350, 700]

我希望将其设为框架值为[50, 50, 140, 140]

的视图的子视图

我希望在不裁剪内容的情况下缩小第一个视图的大小。

这是我的代码:

@IBAction func btnSignPressed(_ sender: Any) {

    for i in 1...drawTag {
        if (i == drawTag) {
            AddSignView = ACEDrawingView()
            AddSignView.tag = 1
            AddSignView.frame = ViewSignature.frame //where ViewSignature Frame is equal to view.frame
            ViewSignature.addSubview(AddSignView)
            DrawingViewCollection.append(AddSignView)
        }
    }
}

@IBAction func btnSavepressed(_ sender: Any) {

    for i in 1...viewTag {
        if (i == viewTag) {
            let person = ZDStickerView()
            let gripFrame1 = CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(140), height: CGFloat(140))
            let contentView = UIView(frame: gripFrame1)

            contentView.clipsToBounds = true
            contentView.addSubview(DrawingViewCollection[i - 1])
            contentView.clipsToBounds = true

            person.frame = gripFrame1
            person.stickerViewDelegate = self
            person.contentView = contentView
            //contentView;
            person.preventsPositionOutsideSuperview = true
            person.translucencySticker = true
            person.showEditingHandles()

            ZdStickerCollection.append(person)
            pdfCollectionView.reloadData()
        }
    }
}

1 个答案:

答案 0 :(得分:1)

停用clipsToBounds媒体资源,将UIView尺寸更改为所需的widthheight值。

yourView.clipsToBounds = false;
yourView.frame = newFrame;