-
Notifications
You must be signed in to change notification settings - Fork 748
/
MarginAdjustable.swift
42 lines (32 loc) · 1.57 KB
/
MarginAdjustable.swift
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
//
// MarginAdjustable.swift
// SwiftMessages
//
// Created by Timothy Moose on 8/5/16.
// Copyright © 2016 SwiftKick Mobile LLC. All rights reserved.
//
import UIKit
/*
Message views that implement the `MarginAdjustable` protocol will have their
`layoutMargins` adjusted by SwiftMessages to account for the height of the
status bar (when displayed under the status bar) and a small amount of
overshoot in the bounce animation. `MessageView` implements this protocol
by way of its parent class `BaseView`.
For the effect of this protocol to work, subviews should be pinned to the
message view's margins and the `layoutMargins` property should not be modified.
This protocol is optional. A message view that doesn't implement `MarginAdjustable`
is responsible for setting is own internal margins appropriately.
*/
public protocol MarginAdjustable {
/// The amount to add to the safe area insets in calculating
/// the layout margins.
var layoutMarginAdditions: UIEdgeInsets { get }
/// When `true`, SwiftMessages automatically collapses layout margin additions (topLayoutMarginAddition, etc.)
/// when the default layout margins are greater than zero. This is typically used when a margin addition is only
/// needed when the safe area inset is zero for a given edge. When the safe area inset for a given edge is non-zero,
/// the additional margin is not added.
var collapseLayoutMarginAdditions: Bool { get set }
/// Start margins from the safe area.
var respectSafeArea: Bool { get set }
var bounceAnimationOffset: CGFloat { get set }
}