Abedalkareem/MaterialTapTargetPrompt-iOS

Wrong position subview and nested view

Closed this issue · 7 comments

Thsi lib works only for top objects(left and right) not center and bottom objects any positions, Are you planning on intergrating this modules ?.

Thanks

I added new positions topLeft, topRight, centerLeft, centerRight, cenertTop, centerBottom
Welcome.

have u tried with custom objects other than barbutton the positioning is still wrong?

screen shot 2017-02-15 at 2 32 38 pm

can u please give me the type of the floating button ?

ok i ended up making changes in your code and now it works for even subviews and nested views
let frame = self.targetView.convert(self.targetView.bounds, to: controller.view)

self.center = CGPoint(x: frame.center.x , y: frame.center.y+yExtraSpace) //center view self.controller.view.addSubview(self)

Good !!
when I replace the code u give to me it's show error (cgrect has no member center) can u share the hole init code with me ?

Sorry i was using an CGRect extension to calculate the center in ma project

extension CGRect {
var x: CGFloat {
    get {
        return self.origin.x
    }
    set {
        self = CGRect(x: newValue, y: self.y, width: self.width, height: self.height)
    }
}

var y: CGFloat {
    get {
        return self.origin.y
    }
    set {
        self = CGRect(x: self.x, y: newValue, width: self.width, height: self.height)
    }
}

var width: CGFloat {
    get {
        return self.size.width
    }
    set {
        self = CGRect(x: self.x, y: self.y, width: newValue, height: self.height)
    }
}

var height: CGFloat {
    get {
        return self.size.height
    }
    set {
        self = CGRect(x: self.x, y: self.y, width: self.width, height: newValue)
    }
}


var top: CGFloat {
    get {
        return self.origin.y
    }
    set {
        y = newValue
    }
}

var bottom: CGFloat {
    get {
        return self.origin.y + self.size.height
    }
    set {
        self = CGRect(x: x, y: newValue - height, width: width, height: height)
    }
}

var left: CGFloat {
    get {
        return self.origin.x
    }
    set {
        self.x = newValue
    }
}

var right: CGFloat {
    get {
        return x + width
    }
    set {
        self = CGRect(x: newValue - width, y: y, width: width, height: height)
    }
}


var midX: CGFloat {
    get {
        return self.x + self.width / 2
    }
    set {
        self = CGRect(x: newValue - width / 2, y: y, width: width, height: height)
    }
}

var midY: CGFloat {
    get {
        return self.y + self.height / 2
    }
    set {
        self = CGRect(x: x, y: newValue - height / 2, width: width, height: height)
    }
}


var center: CGPoint {
    get {
        return CGPoint(x: self.midX, y: self.midY)
    }
    set {
        self = CGRect(x: newValue.x - width / 2, y: newValue.y - height / 2, width: width, height: height)
    }
}

}

It's work , Thank u !