i have a little problem. As you can see i have created a triangle (which is "context") and the triangle's angle (which is "retVinkel") using Core graphics. Now, when i run the app on Iphone 6s it looks just fine, right in the middle where i want it and the right size. Of course the triangles width, height and position will be the same because i have written the coordinates inside the UIView, for instance with the iPad air it will be in the right corner and not in the middle.
But how can i do so that the triangle stays in the middle and expand if the screen size expand so it will fill the same amount of space in every device. Can i say like "move 20% pixels to the right and 30% pixels down" so the triangle's area will be affected by the screen size.
import UIKit
class TriangleDraw: UIView {
override func drawRect(rect: CGRect) {
let context = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(context, 2.0)
CGContextSetStrokeColorWithColor(context, UIColor.blackColor().CGColor)
CGContextMoveToPoint(context, 75, 400)
CGContextAddLineToPoint(context, 325, 400)
CGContextAddLineToPoint(context, 325, 225)
CGContextAddLineToPoint(context, 75, 400)
let retVinkel = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(retVinkel, 2.0)
CGContextSetStrokeColorWithColor(retVinkel, UIColor.blackColor().CGColor)
CGContextMoveToPoint(retVinkel, 300, 400)
CGContextAddLineToPoint(retVinkel, 300, 375)
CGContextAddLineToPoint(retVinkel, 325, 375)
CGContextStrokePath(context)
CGContextStrokePath(retVinkel)
}
}