Manos Chorianopoulos

redesign MFYViewController

...@@ -37,8 +37,8 @@ import UIKit ...@@ -37,8 +37,8 @@ import UIKit
37 public override func awakeFromNib() { 37 public override func awakeFromNib() {
38 super.awakeFromNib() 38 super.awakeFromNib()
39 39
40 - inboxView.layer.cornerRadius = 5.0 40 +// inboxView.layer.cornerRadius = 5.0
41 - inboxView.clipsToBounds = true 41 +// inboxView.clipsToBounds = true
42 42
43 newBadgeImage.image = UIImage(named: "new_icon_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 43 newBadgeImage.image = UIImage(named: "new_icon_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
44 curvedBgImage.image = UIImage(named: "curved_bg_white_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) 44 curvedBgImage.image = UIImage(named: "curved_bg_white_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
...@@ -57,6 +57,26 @@ import UIKit ...@@ -57,6 +57,26 @@ import UIKit
57 //set the values for top,left,bottom,right margins 57 //set the values for top,left,bottom,right margins
58 let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0) 58 let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
59 contentView.frame = contentView.frame.inset(by: margins) 59 contentView.frame = contentView.frame.inset(by: margins)
60 +
61 + // Add different corner radius - Do it here, otherwise it won't be applied to all cells
62 + inboxView.roundCorners(topLeft: 20, topRight: 45, bottomLeft: 20, bottomRight: 0)
63 +
64 + // Delete extra borderLayers added
65 + for layer in (inboxView.layer.sublayers ?? []) {
66 + if(layer.name == "MFYItemBorderLayer"){
67 + layer.removeFromSuperlayer()
68 + }
69 + }
70 +
71 + // Add borderLayer
72 + let borderLayer = CAShapeLayer()
73 + borderLayer.path = (inboxView.layer.mask! as! CAShapeLayer).path! // Reuse the Bezier path
74 + borderLayer.strokeColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
75 + borderLayer.fillColor = UIColor.clear.cgColor
76 + borderLayer.lineWidth = 1
77 + borderLayer.frame = inboxView.bounds
78 + borderLayer.name = "MFYItemBorderLayer"
79 + inboxView.layer.addSublayer(borderLayer)
60 } 80 }
61 81
62 82
...@@ -65,11 +85,11 @@ import UIKit ...@@ -65,11 +85,11 @@ import UIKit
65 self.postImageURL = campaign.logo_url ?? "" 85 self.postImageURL = campaign.logo_url ?? ""
66 86
67 campaignTitleLabel.text = campaign.title ?? "" 87 campaignTitleLabel.text = campaign.title ?? ""
68 - campaignTitleLabel.font = UIFont(name: "PFSquareSansPro-BoldItalic", size: 18) 88 + campaignTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
69 subtitleLabel.text = campaign.subtitle ?? "" 89 subtitleLabel.text = campaign.subtitle ?? ""
70 - subtitleLabel.font = UIFont(name: "PFSquareSansPro-Regular", size: 16) 90 + subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 15)
71 descriptionLabel.text = campaign.message ?? "" 91 descriptionLabel.text = campaign.message ?? ""
72 - descriptionLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 14) 92 + descriptionLabel.font = UIFont(name: "PeridotPE-SBold", size: 15)
73 93
74 if (campaign.is_new == true) { 94 if (campaign.is_new == true) {
75 newBadgeImage.isHidden = false 95 newBadgeImage.isHidden = false
...@@ -83,11 +103,11 @@ import UIKit ...@@ -83,11 +103,11 @@ import UIKit
83 self.postImageURL = ccms._imageUrl 103 self.postImageURL = ccms._imageUrl
84 104
85 campaignTitleLabel.text = ccms._title 105 campaignTitleLabel.text = ccms._title
86 - campaignTitleLabel.font = UIFont(name: "PFSquareSansPro-BoldItalic", size: 18) 106 + campaignTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
87 subtitleLabel.text = ccms._subtitle 107 subtitleLabel.text = ccms._subtitle
88 - subtitleLabel.font = UIFont(name: "PFSquareSansPro-Regular", size: 16) 108 + subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 15)
89 descriptionLabel.text = ccms._description 109 descriptionLabel.text = ccms._description
90 - descriptionLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 14) 110 + descriptionLabel.font = UIFont(name: "PeridotPE-SBold", size: 15)
91 111
92 newBadgeImage.isHidden = true 112 newBadgeImage.isHidden = true
93 } 113 }
......
...@@ -54,30 +54,30 @@ import SwiftEventBus ...@@ -54,30 +54,30 @@ import SwiftEventBus
54 // tableView.clipsToBounds = true 54 // tableView.clipsToBounds = true
55 // tableView.layer.cornerRadius = 30 55 // tableView.layer.cornerRadius = 30
56 // tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius 56 // tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
57 - tableView.contentInset.top = 50 57 + tableView.contentInset.top = 10
58 58
59 // Add Top left corner radius 59 // Add Top left corner radius
60 // mainView.clipsToBounds = true 60 // mainView.clipsToBounds = true
61 // mainView.layer.cornerRadius = 30 61 // mainView.layer.cornerRadius = 30
62 // mainView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius 62 // mainView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
63 - mainView.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 1.00) 63 + mainView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
64 64
65 - let image = UIImage(named: "top_border_shadow", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)! 65 +// let image = UIImage(named: "top_border_shadow", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
66 - var aspectR: CGFloat = 0.0 66 +// var aspectR: CGFloat = 0.0
67 - 67 +//
68 - aspectR = image.size.width/image.size.height 68 +// aspectR = image.size.width/image.size.height
69 - 69 +//
70 - topBorderShadow.translatesAutoresizingMaskIntoConstraints = false 70 +// topBorderShadow.translatesAutoresizingMaskIntoConstraints = false
71 - topBorderShadow.image = image 71 +// topBorderShadow.image = image
72 - topBorderShadow.contentMode = .scaleAspectFill 72 +// topBorderShadow.contentMode = .scaleAspectFill
73 - 73 +//
74 - NSLayoutConstraint.activate([ 74 +// NSLayoutConstraint.activate([
75 - topBorderShadow.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0), 75 +// topBorderShadow.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
76 - topBorderShadow.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0), 76 +// topBorderShadow.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
77 - topBorderShadow.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0), 77 +// topBorderShadow.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
78 - topBorderShadow.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width), 78 +// topBorderShadow.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
79 - topBorderShadow.heightAnchor.constraint(equalTo: topBorderShadow.widthAnchor, multiplier: 1/aspectR) 79 +// topBorderShadow.heightAnchor.constraint(equalTo: topBorderShadow.widthAnchor, multiplier: 1/aspectR)
80 - ]) 80 +// ])
81 81
82 } 82 }
83 83
...@@ -211,8 +211,8 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -211,8 +211,8 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
211 view.backgroundColor = .clear 211 view.backgroundColor = .clear
212 212
213 let titleLabel = UILabel(frame: CGRect(x: 20, y: 5, width: view.frame.width - 20, height: 43)) 213 let titleLabel = UILabel(frame: CGRect(x: 20, y: 5, width: view.frame.width - 20, height: 43))
214 - titleLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 21) 214 + titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 15)
215 - titleLabel.textColor = UIColor(rgb: 0xF4F4F4) 215 + titleLabel.textColor = UIColor(rgb: 0x212121)
216 titleLabel.text = categories[section].name 216 titleLabel.text = categories[section].name
217 217
218 view.addSubview(titleLabel) 218 view.addSubview(titleLabel)
......
...@@ -245,30 +245,30 @@ ...@@ -245,30 +245,30 @@
245 <rect key="frame" x="20" y="0.0" width="374" height="118.5"/> 245 <rect key="frame" x="20" y="0.0" width="374" height="118.5"/>
246 <subviews> 246 <subviews>
247 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="rO0-9o-lPR"> 247 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="rO0-9o-lPR">
248 - <rect key="frame" x="198" y="0.0" width="176" height="118.5"/> 248 + <rect key="frame" x="179.5" y="0.0" width="194.5" height="118.5"/>
249 </imageView> 249 </imageView>
250 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wwZ-Gb-7yh" userLabel="InfoView"> 250 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wwZ-Gb-7yh" userLabel="InfoView">
251 - <rect key="frame" x="0.0" y="0.0" width="299" height="118.5"/> 251 + <rect key="frame" x="0.0" y="0.0" width="280.5" height="118.5"/>
252 <subviews> 252 <subviews>
253 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="curved_bg_white" translatesAutoresizingMaskIntoConstraints="NO" id="VSX-eK-ySx"> 253 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="curved_bg_white" translatesAutoresizingMaskIntoConstraints="NO" id="VSX-eK-ySx">
254 - <rect key="frame" x="0.0" y="0.0" width="299" height="118.5"/> 254 + <rect key="frame" x="0.0" y="0.0" width="280.5" height="118.5"/>
255 </imageView> 255 </imageView>
256 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZGH-0a-Rkp"> 256 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZGH-0a-Rkp">
257 - <rect key="frame" x="20" y="10" width="229" height="21"/> 257 + <rect key="frame" x="20" y="10" width="210.5" height="20"/>
258 - <fontDescription key="fontDescription" name="PFSquareSansPro-BoldItalic" family="PF Square Sans Pro" pointSize="18"/> 258 + <fontDescription key="fontDescription" name="BTCosmo-Bold" family="BTCosmo" pointSize="17"/>
259 - <color key="textColor" red="0.22745098039215686" green="0.32156862745098036" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/> 259 + <color key="textColor" red="0.12941176470588234" green="0.12941176470588234" blue="0.12941176470588234" alpha="1" colorSpace="calibratedRGB"/>
260 <nil key="highlightedColor"/> 260 <nil key="highlightedColor"/>
261 </label> 261 </label>
262 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lIv-wc-Oa8"> 262 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lIv-wc-Oa8">
263 - <rect key="frame" x="20" y="36" width="229" height="19"/> 263 + <rect key="frame" x="20" y="35" width="210.5" height="18.5"/>
264 - <fontDescription key="fontDescription" name="PFSquareSansPro-Regular" family="PF Square Sans Pro" pointSize="16"/> 264 + <fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="15"/>
265 - <color key="textColor" red="0.22745098039215686" green="0.32156862745098036" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/> 265 + <color key="textColor" red="0.12941176470588234" green="0.12941176470588234" blue="0.12941176470588234" alpha="1" colorSpace="calibratedRGB"/>
266 <nil key="highlightedColor"/> 266 <nil key="highlightedColor"/>
267 </label> 267 </label>
268 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bmR-su-WJq"> 268 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bmR-su-WJq">
269 - <rect key="frame" x="20" y="92" width="229" height="16.5"/> 269 + <rect key="frame" x="20" y="90" width="210.5" height="18.5"/>
270 - <fontDescription key="fontDescription" name="PFSquareSansPro-Bold" family="PF Square Sans Pro" pointSize="14"/> 270 + <fontDescription key="fontDescription" name="PeridotPE-SBold" family="Peridot PE" pointSize="15"/>
271 - <color key="textColor" red="0.22745098039215686" green="0.32156862745098036" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/> 271 + <color key="textColor" red="0.12941176470588234" green="0.12941176470588234" blue="0.12941176470588234" alpha="1" colorSpace="calibratedRGB"/>
272 <nil key="highlightedColor"/> 272 <nil key="highlightedColor"/>
273 </label> 273 </label>
274 </subviews> 274 </subviews>
...@@ -295,10 +295,10 @@ ...@@ -295,10 +295,10 @@
295 <constraints> 295 <constraints>
296 <constraint firstAttribute="trailing" secondItem="rO0-9o-lPR" secondAttribute="trailing" id="1ML-M9-7re"/> 296 <constraint firstAttribute="trailing" secondItem="rO0-9o-lPR" secondAttribute="trailing" id="1ML-M9-7re"/>
297 <constraint firstItem="wwZ-Gb-7yh" firstAttribute="leading" secondItem="gk0-7d-Ok4" secondAttribute="leading" id="4zX-6H-wCP"/> 297 <constraint firstItem="wwZ-Gb-7yh" firstAttribute="leading" secondItem="gk0-7d-Ok4" secondAttribute="leading" id="4zX-6H-wCP"/>
298 - <constraint firstItem="rO0-9o-lPR" firstAttribute="width" secondItem="gk0-7d-Ok4" secondAttribute="width" multiplier="0.47" id="Nx2-CC-7uS"/> 298 + <constraint firstItem="rO0-9o-lPR" firstAttribute="width" secondItem="gk0-7d-Ok4" secondAttribute="width" multiplier="0.52" id="Nx2-CC-7uS"/>
299 <constraint firstAttribute="bottom" secondItem="wwZ-Gb-7yh" secondAttribute="bottom" id="R9h-bH-ljJ"/> 299 <constraint firstAttribute="bottom" secondItem="wwZ-Gb-7yh" secondAttribute="bottom" id="R9h-bH-ljJ"/>
300 <constraint firstAttribute="bottom" secondItem="rO0-9o-lPR" secondAttribute="bottom" id="j9C-vp-fe1"/> 300 <constraint firstAttribute="bottom" secondItem="rO0-9o-lPR" secondAttribute="bottom" id="j9C-vp-fe1"/>
301 - <constraint firstItem="wwZ-Gb-7yh" firstAttribute="width" secondItem="gk0-7d-Ok4" secondAttribute="width" multiplier="0.8" id="jgZ-ZW-oVV"/> 301 + <constraint firstItem="wwZ-Gb-7yh" firstAttribute="width" secondItem="gk0-7d-Ok4" secondAttribute="width" multiplier="0.75" id="jgZ-ZW-oVV"/>
302 <constraint firstItem="rO0-9o-lPR" firstAttribute="top" secondItem="gk0-7d-Ok4" secondAttribute="top" id="qFk-ry-HF3"/> 302 <constraint firstItem="rO0-9o-lPR" firstAttribute="top" secondItem="gk0-7d-Ok4" secondAttribute="top" id="qFk-ry-HF3"/>
303 <constraint firstItem="wwZ-Gb-7yh" firstAttribute="top" secondItem="gk0-7d-Ok4" secondAttribute="top" id="zzi-VV-ocs"/> 303 <constraint firstItem="wwZ-Gb-7yh" firstAttribute="top" secondItem="gk0-7d-Ok4" secondAttribute="top" id="zzi-VV-ocs"/>
304 </constraints> 304 </constraints>
...@@ -339,11 +339,11 @@ ...@@ -339,11 +339,11 @@
339 <outlet property="delegate" destination="YRk-Az-LOb" id="xhM-mG-VTI"/> 339 <outlet property="delegate" destination="YRk-Az-LOb" id="xhM-mG-VTI"/>
340 </connections> 340 </connections>
341 </tableView> 341 </tableView>
342 - <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8mV-zg-aKO"> 342 + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="8mV-zg-aKO">
343 <rect key="frame" x="0.0" y="420" width="414" height="11.5"/> 343 <rect key="frame" x="0.0" y="420" width="414" height="11.5"/>
344 </imageView> 344 </imageView>
345 </subviews> 345 </subviews>
346 - <color key="backgroundColor" red="0.21960784310000001" green="0.32156862749999998" blue="0.4039215686" alpha="1" colorSpace="calibratedRGB"/> 346 + <color key="backgroundColor" red="0.94901960784313721" green="0.94901960784313721" blue="0.95294117647058818" alpha="1" colorSpace="calibratedRGB"/>
347 <constraints> 347 <constraints>
348 <constraint firstAttribute="bottom" secondItem="A8b-3b-5xc" secondAttribute="bottom" id="9LG-av-UIJ"/> 348 <constraint firstAttribute="bottom" secondItem="A8b-3b-5xc" secondAttribute="bottom" id="9LG-av-UIJ"/>
349 <constraint firstItem="A8b-3b-5xc" firstAttribute="top" secondItem="NSn-MS-EVn" secondAttribute="top" id="Gfl-IG-H5C"/> 349 <constraint firstItem="A8b-3b-5xc" firstAttribute="top" secondItem="NSn-MS-EVn" secondAttribute="top" id="Gfl-IG-H5C"/>
...@@ -353,6 +353,11 @@ ...@@ -353,6 +353,11 @@
353 <constraint firstItem="8mV-zg-aKO" firstAttribute="top" secondItem="NSn-MS-EVn" secondAttribute="top" id="jVC-qs-cac"/> 353 <constraint firstItem="8mV-zg-aKO" firstAttribute="top" secondItem="NSn-MS-EVn" secondAttribute="top" id="jVC-qs-cac"/>
354 <constraint firstAttribute="trailing" secondItem="8mV-zg-aKO" secondAttribute="trailing" id="zBg-nO-B4w"/> 354 <constraint firstAttribute="trailing" secondItem="8mV-zg-aKO" secondAttribute="trailing" id="zBg-nO-B4w"/>
355 </constraints> 355 </constraints>
356 + <variation key="default">
357 + <mask key="subviews">
358 + <exclude reference="8mV-zg-aKO"/>
359 + </mask>
360 + </variation>
356 </view> 361 </view>
357 </subviews> 362 </subviews>
358 <viewLayoutGuide key="safeArea" id="THS-z4-i7u"/> 363 <viewLayoutGuide key="safeArea" id="THS-z4-i7u"/>
......
...@@ -523,3 +523,87 @@ class UnselectableTappableTextView: UITextView { ...@@ -523,3 +523,87 @@ class UnselectableTappableTextView: UITextView {
523 return false 523 return false
524 } 524 }
525 } 525 }
526 +
527 +extension UIBezierPath {
528 + convenience init(shouldRoundRect rect: CGRect, topLeftRadius: CGSize = .zero, topRightRadius: CGSize = .zero, bottomLeftRadius: CGSize = .zero, bottomRightRadius: CGSize = .zero){
529 +
530 + self.init()
531 +
532 + let path = CGMutablePath()
533 +
534 + let topLeft = rect.origin
535 + let topRight = CGPoint(x: rect.maxX, y: rect.minY)
536 + let bottomRight = CGPoint(x: rect.maxX, y: rect.maxY)
537 + let bottomLeft = CGPoint(x: rect.minX, y: rect.maxY)
538 +
539 + if topLeftRadius != .zero{
540 + path.move(to: CGPoint(x: topLeft.x+topLeftRadius.width, y: topLeft.y))
541 + } else {
542 + path.move(to: CGPoint(x: topLeft.x, y: topLeft.y))
543 + }
544 +
545 + if topRightRadius != .zero{
546 + path.addLine(to: CGPoint(x: topRight.x-topRightRadius.width, y: topRight.y))
547 + path.addCurve(to: CGPoint(x: topRight.x, y: topRight.y+topRightRadius.height), control1: CGPoint(x: topRight.x, y: topRight.y), control2:CGPoint(x: topRight.x, y: topRight.y+topRightRadius.height))
548 + } else {
549 + path.addLine(to: CGPoint(x: topRight.x, y: topRight.y))
550 + }
551 +
552 + if bottomRightRadius != .zero{
553 + path.addLine(to: CGPoint(x: bottomRight.x, y: bottomRight.y-bottomRightRadius.height))
554 + path.addCurve(to: CGPoint(x: bottomRight.x-bottomRightRadius.width, y: bottomRight.y), control1: CGPoint(x: bottomRight.x, y: bottomRight.y), control2: CGPoint(x: bottomRight.x-bottomRightRadius.width, y: bottomRight.y))
555 + } else {
556 + path.addLine(to: CGPoint(x: bottomRight.x, y: bottomRight.y))
557 + }
558 +
559 + if bottomLeftRadius != .zero{
560 + path.addLine(to: CGPoint(x: bottomLeft.x+bottomLeftRadius.width, y: bottomLeft.y))
561 + path.addCurve(to: CGPoint(x: bottomLeft.x, y: bottomLeft.y-bottomLeftRadius.height), control1: CGPoint(x: bottomLeft.x, y: bottomLeft.y), control2: CGPoint(x: bottomLeft.x, y: bottomLeft.y-bottomLeftRadius.height))
562 + } else {
563 + path.addLine(to: CGPoint(x: bottomLeft.x, y: bottomLeft.y))
564 + }
565 +
566 + if topLeftRadius != .zero{
567 + path.addLine(to: CGPoint(x: topLeft.x, y: topLeft.y+topLeftRadius.height))
568 + path.addCurve(to: CGPoint(x: topLeft.x+topLeftRadius.width, y: topLeft.y) , control1: CGPoint(x: topLeft.x, y: topLeft.y) , control2: CGPoint(x: topLeft.x+topLeftRadius.width, y: topLeft.y))
569 + } else {
570 + path.addLine(to: CGPoint(x: topLeft.x, y: topLeft.y))
571 + }
572 +
573 + path.closeSubpath()
574 + cgPath = path
575 + }
576 +}
577 +
578 +extension UIView{
579 + func roundCorners(topLeft: CGFloat = 0, topRight: CGFloat = 0, bottomLeft: CGFloat = 0, bottomRight: CGFloat = 0) {//(topLeft: CGFloat, topRight: CGFloat, bottomLeft: CGFloat, bottomRight: CGFloat) {
580 + let topLeftRadius = CGSize(width: topLeft, height: topLeft)
581 + let topRightRadius = CGSize(width: topRight, height: topRight)
582 + let bottomLeftRadius = CGSize(width: bottomLeft, height: bottomLeft)
583 + let bottomRightRadius = CGSize(width: bottomRight, height: bottomRight)
584 + let maskPath = UIBezierPath(shouldRoundRect: bounds, topLeftRadius: topLeftRadius, topRightRadius: topRightRadius, bottomLeftRadius: bottomLeftRadius, bottomRightRadius: bottomRightRadius)
585 + let shape = CAShapeLayer()
586 + shape.path = maskPath.cgPath
587 + layer.mask = shape
588 + }
589 +}
590 +
591 +extension UIView {
592 + func applyRadiusMaskFor(topLeft: CGFloat = 0, bottomLeft: CGFloat = 0, bottomRight: CGFloat = 0, topRight: CGFloat = 0) {
593 +
594 + let path = UIBezierPath()
595 + path.move(to: CGPoint(x: bounds.width - topRight, y: 0))
596 + path.addLine(to: CGPoint(x: topLeft, y: 0))
597 + path.addQuadCurve(to: CGPoint(x: 0, y: topLeft), controlPoint: .zero)
598 + path.addLine(to: CGPoint(x: 0, y: bounds.height - bottomLeft))
599 + path.addQuadCurve(to: CGPoint(x: bottomLeft, y: bounds.height), controlPoint: CGPoint(x: 0, y: bounds.height))
600 + path.addLine(to: CGPoint(x: bounds.width - bottomRight, y: bounds.height))
601 + path.addQuadCurve(to: CGPoint(x: bounds.width, y: bounds.height - bottomRight), controlPoint: CGPoint(x: bounds.width, y: bounds.height))
602 + path.addLine(to: CGPoint(x: bounds.width, y: topRight))
603 + path.addQuadCurve(to: CGPoint(x: bounds.width - topRight, y: 0), controlPoint: CGPoint(x: bounds.width, y: 0))
604 +
605 + let shape = CAShapeLayer()
606 + shape.path = path.cgPath
607 + layer.mask = shape
608 + }
609 +}
......