خرید بک لینک

Vote count: 0

I am trying to create a UIView in my CollectionViewCell, but I should set it a frame first. I tried this approach, but this doesn't seem quite right. How can I get the center frame of the view for the soon-to-be-created subview?

    var cellWidth = self.frame.size.width / 2
    var cellHeight = self.frame.size.height
    var subviewWidth = (self.frame.size.width/2
    var subviewHeight = (self.frame.size.height/2
    var xpos = (viewWidth/2.0) - (subviewWidth/2.0)
    var ypos = (viewHeight/2.0) - (subviewHeight/2.0)

    let frame = CGRect(x: xpos, y: ypos, width: subviewWidth, height: subviewHeight)

    // setup item with frame

    self.addSubview(item)

asked 3 mins ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 4 ارديبهشت 1395 ساعت: 18:42

صفحه بندی