58 lines
1.5 KiB
Swift
58 lines
1.5 KiB
Swift
//
|
|
// SegmentioCellWithLabel.swift
|
|
// Segmentio
|
|
//
|
|
// Created by Dmitriy Demchenko
|
|
// Copyright © 2016 Yalantis Mobile. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
final class SegmentioCellWithLabel: SegmentioCell {
|
|
|
|
override func setupConstraintsForSubviews() {
|
|
super.setupConstraintsForSubviews()
|
|
|
|
guard let containerView = containerView else {
|
|
return
|
|
}
|
|
|
|
let views = ["containerView": containerView]
|
|
|
|
// main constraints
|
|
|
|
let segmentTitleLabelHorizontConstraint = NSLayoutConstraint.constraints(
|
|
withVisualFormat: "|[containerView]|", //changed from |-[containerView]-|. remove standard space
|
|
options: [.alignAllCenterX],
|
|
metrics: nil,
|
|
views: views
|
|
)
|
|
NSLayoutConstraint.activate(segmentTitleLabelHorizontConstraint)
|
|
|
|
// custom constraints
|
|
|
|
topConstraint = NSLayoutConstraint(
|
|
item: containerView,
|
|
attribute: .top,
|
|
relatedBy: .equal,
|
|
toItem: contentView,
|
|
attribute: .top,
|
|
multiplier: 1,
|
|
constant: padding
|
|
)
|
|
topConstraint?.isActive = true
|
|
|
|
bottomConstraint = NSLayoutConstraint(
|
|
item: contentView,
|
|
attribute: .bottom,
|
|
relatedBy: .equal,
|
|
toItem: containerView,
|
|
attribute: .bottom,
|
|
multiplier: 1,
|
|
constant: padding
|
|
)
|
|
bottomConstraint?.isActive = true
|
|
}
|
|
|
|
}
|