BinaryFloatingPoint.swift
1016 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// File.swift
// browser
//
// Created by Artem Talko on 27.09.2023.
//
import UIKit
extension BinaryFloatingPoint {
private var size: CGSize {
return CGSize(width: 375, height: 812)
}
var sizeW: CGFloat {
(CGFloat(self) * UIScreen.main.bounds.width / size.width)
}
var sizeH: CGFloat {
(CGFloat(self) * UIScreen.main.bounds.height / size.height)
}
var lessThanOrEqualToSizeW: CGFloat {
UIScreen.main.bounds.width < size.width ? self.sizeW : CGFloat(self)
}
var lessThanOrEqualToSizeH: CGFloat {
UIScreen.main.bounds.height < size.height ? self.sizeH : CGFloat(self)
}
}
extension BinaryInteger {
var sizeW: CGFloat {
CGFloat(self).sizeW
}
var sizeH: CGFloat {
CGFloat(self).sizeH
}
var lessThanOrEqualToSizeW: CGFloat {
CGFloat(self).lessThanOrEqualToSizeW
}
var lessThanOrEqualToSizeH: CGFloat {
CGFloat(self).lessThanOrEqualToSizeH
}
}