SHARE
TWEET

WordCell

a guest Sep 22nd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  WordCell.swift
  3. //  First screen
  4. //
  5. //  Created by karolis on 18/09/2019.
  6. //  Copyright © 2019 karolis. All rights reserved.
  7. //
  8.  
  9. import Foundation
  10. import  UIKit
  11.  
  12. class WordCell: UICollectionViewCell{
  13.    
  14.     override init(frame: CGRect) {
  15.         super.init(frame: frame)
  16.         setupViews()
  17.        
  18.     }
  19.    
  20.     let adressLabel: UILabel = {
  21.         let label = UILabel()
  22.         label.text = "DEMO GATVE 12A, Vilnius"
  23.         label.textColor = .white
  24.         label.font = label.font.withSize(10)
  25.         label.translatesAutoresizingMaskIntoConstraints = false
  26.         return label
  27.     }()
  28.    
  29.     let distanceLabel: UILabel = {
  30.         let label = UILabel()
  31.         label.text = "84km"
  32.         label.textAlignment = .right
  33.         label.textColor = .white
  34.         label.font = label.font.withSize(10)
  35.         label.translatesAutoresizingMaskIntoConstraints = false
  36.         return label
  37.     }()
  38.    
  39.     let adressView: UIView = {
  40.         let view = UIView()
  41.         view.backgroundColor = .blue
  42.         view.layer.cornerRadius = 2
  43.         view.translatesAutoresizingMaskIntoConstraints = false
  44.         return view
  45.     }()
  46.    
  47.     let workIdLabel: UILabel = {
  48.         let label = UILabel()
  49.         label.text = "V19-074213"
  50.         label.font = UIFont.boldSystemFont(ofSize: 14)
  51.         label.translatesAutoresizingMaskIntoConstraints = false
  52.         return label
  53.     }()
  54.    
  55.     let workNameLabel: UILabel = {
  56.         let label = UILabel()
  57.         label.text = "test"
  58.         label.textColor = UIColor.black.withAlphaComponent(0.5)
  59.         label.font = label.font.withSize(12)
  60.         label.translatesAutoresizingMaskIntoConstraints = false
  61.         return label
  62.     }()
  63.    
  64.     let firstStatusLabel: UILabel = {
  65.         let label = UILabel()
  66.         label.text = "Veluoja"
  67.         label.backgroundColor = .red
  68.         label.textColor = .white
  69.         label.font = label.font.withSize(14)
  70.         label.textAlignment = .center
  71.         label.clipsToBounds = true
  72.         label.layer.cornerRadius = 5
  73.         label.translatesAutoresizingMaskIntoConstraints = false
  74.         return label
  75.     }()
  76.    
  77.     let secondStatusLabel: UILabel = {
  78.         let label = UILabel()
  79.         label.text = "2019-09-28"
  80.         label.backgroundColor = .orange
  81.         label.textColor = .white
  82.         label.font = label.font.withSize(14)
  83.         label.textAlignment = .center
  84.         label.clipsToBounds = true
  85.         label.layer.cornerRadius = 5
  86.         label.translatesAutoresizingMaskIntoConstraints = false
  87.         return label
  88.     }()
  89.    
  90.     func setupViews(){
  91.         addSubview(adressView)
  92.         adressView.addSubview(adressLabel)
  93.         adressView.addSubview(distanceLabel)
  94.        
  95.         addSubview(workIdLabel)
  96.         addSubview(workNameLabel)
  97.         addSubview(firstStatusLabel)
  98.         addSubview(secondStatusLabel)
  99.        
  100.        
  101.         setupConstraints()
  102.     }
  103.    
  104.    
  105.     func setupConstraints() {
  106.         let adressBarHeight: CGFloat = 20
  107.         let componentPadding : CGFloat = 10
  108.        
  109.         ///MARK: - BLUE BAR
  110.         adressView.topAnchor.constraint(equalTo: topAnchor).isActive = true
  111.         adressView.leadingAnchor.constraint(equalTo: leadingAnchor).isActive = true
  112.         adressView.trailingAnchor.constraint(equalTo: trailingAnchor).isActive = true
  113.         adressView.heightAnchor.constraint(equalToConstant: adressBarHeight).isActive = true
  114.        
  115.         adressLabel.topAnchor.constraint(equalTo: adressView.topAnchor).isActive = true
  116.         adressLabel.bottomAnchor.constraint(equalTo: adressView.bottomAnchor).isActive = true
  117.         adressLabel.leftAnchor.constraint(equalTo: adressView.leftAnchor, constant: componentPadding).isActive = true
  118.         adressLabel.widthAnchor.constraint(equalTo: adressView.widthAnchor, multiplier: 1/2).isActive = true
  119.        
  120.         distanceLabel.topAnchor.constraint(equalTo: adressView.topAnchor).isActive = true
  121.         distanceLabel.bottomAnchor.constraint(equalTo: adressView.bottomAnchor).isActive = true
  122.         distanceLabel.leftAnchor.constraint(equalTo: adressLabel.rightAnchor).isActive = true
  123.         distanceLabel.rightAnchor.constraint(equalTo: adressView.rightAnchor, constant: -componentPadding).isActive = true
  124.        
  125.         workIdLabel.topAnchor.constraint(equalTo: adressView.bottomAnchor).isActive = true
  126.         workIdLabel.leftAnchor.constraint(equalTo: adressLabel.leftAnchor).isActive = true
  127.         workIdLabel.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 1/2).isActive = true
  128.         workIdLabel.heightAnchor.constraint(equalToConstant: 25).isActive = true
  129.        
  130.         workNameLabel.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
  131.         workNameLabel.heightAnchor.constraint(equalToConstant: 20).isActive = true
  132.         workNameLabel.leftAnchor.constraint(equalTo: workIdLabel.leftAnchor).isActive = true
  133.         workNameLabel.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
  134.        
  135.         firstStatusLabel.topAnchor.constraint(equalTo: adressView.bottomAnchor).isActive = true
  136.         firstStatusLabel.bottomAnchor.constraint(equalTo: workIdLabel.bottomAnchor).isActive = true
  137.         firstStatusLabel.rightAnchor.constraint(equalTo: rightAnchor).isActive = true
  138.         firstStatusLabel.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 1/6).isActive = true
  139.        
  140.        
  141.         secondStatusLabel.topAnchor.constraint(equalTo: firstStatusLabel.topAnchor).isActive = true
  142.         secondStatusLabel.bottomAnchor.constraint(equalTo: firstStatusLabel.bottomAnchor).isActive = true
  143.         secondStatusLabel.leftAnchor.constraint(equalTo: workIdLabel.rightAnchor).isActive = true
  144.         secondStatusLabel.rightAnchor.constraint(equalTo: firstStatusLabel.leftAnchor).isActive = true
  145.        
  146.     }
  147.    
  148.     required init?(coder aDecoder: NSCoder) {
  149.         fatalError("init(coder:) has not been implemented")
  150.     }
  151. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top