Reputation: 4886
I am trying to have two UIButtons. One is 8 points from the edge of the UIView they are inside and the second one is 4 points from the start of the first. I am currently doing this
let buttonFrames: CGSize = CGSizeMake(56, 42)
let buttonRightPosition: CGPoint = CGPointMake(frame.size.width - 8, frame.size.height - 62)
let buttonLeftPosition: CGPoint = CGPointMake(buttonRightPosition - 60, frame.size.height)
Both buttons will have the frame 56x42 but I will also add size to fit both buttons. So, that is why I need to adjust the second one accordingly. When I do this an error occurs in variable buttonLeftPosition. I am trying to find any way to place a view in relation to another view in the same class.
Upvotes: 2
Views: 2197
Reputation: 15635
buttonRightPosition
is a CGPoint
. In your last line, when you are trying to create the buttonLeftPosition
CGPoint
, you have to use buttonRightPosition.x
to access its x
position..
Note: In Swift I would use the CGSize
and CGPoint
initializers instead of CGSizeMake()
or CGPointMake()
let buttonFrames = CGSize(width: 56, height: 42)
let buttonRightPosition = CGPoint(x: frame.size.width - 8, y: frame.size.height - 62)
let buttonLeftPosition = CGPoint(x: buttonRightPosition.x - 60, y: frame.size.height)
Upvotes: 1