Files
iOS/Sources/Shared/Common/Extensions/NSLayoutConstraint+Additions.swift
Zac West a1c57ec46e Static image attachments in dynamic category (#1596)
Refs #1591.

## Summary
Adds support for using image notification attachments in the content extension.

## Screenshots
<img width="350" src="https://user-images.githubusercontent.com/74188/115494743-18462900-a21b-11eb-83d5-3e6c112d99df.png">

## Any other notes
Dynamic actions require the 'DYNAMIC' category but our content extension causes attachments to not appear and we want every possible feature to work with just this category.
2021-04-20 22:10:17 -07:00

13 lines
360 B
Swift

import UIKit
public extension NSLayoutConstraint {
static func aspectRatioConstraint(on view: UIView, size: CGSize) -> NSLayoutConstraint? {
guard size.height > 0 else {
return nil
}
let ratio = size.width / size.height
return view.widthAnchor.constraint(equalTo: view.heightAnchor, multiplier: ratio)
}
}