mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00

git-subtree-dir: submodules/AsyncDisplayKit git-subtree-mainline: d06f423e0ed3df1fed9bd10d79ee312a9179b632 git-subtree-split: 02bedc12816e251ad71777f9d2578329b6d2bef6
41 lines
1.3 KiB
Swift
41 lines
1.3 KiB
Swift
//
|
|
// PhotoWithInsetTextOverlay.swift
|
|
// Texture
|
|
//
|
|
// Copyright (c) Pinterest, Inc. All rights reserved.
|
|
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
import AsyncDisplayKit
|
|
|
|
public class PhotoWithInsetTextOverlay: ASDisplayNode, ASPlayground {
|
|
public let photoNode = ASNetworkImageNode()
|
|
public let titleNode = ASTextNode()
|
|
|
|
override public init() {
|
|
super.init()
|
|
backgroundColor = .white
|
|
|
|
automaticallyManagesSubnodes = true
|
|
setupNodes()
|
|
}
|
|
|
|
private func setupNodes() {
|
|
photoNode.url = URL(string: "http://asyncdisplaykit.org/static/images/layout-examples-photo-with-inset-text-overlay-photo.png")
|
|
photoNode.backgroundColor = .black
|
|
|
|
titleNode.backgroundColor = .blue
|
|
titleNode.maximumNumberOfLines = 2
|
|
titleNode.truncationAttributedText = NSAttributedString.attributedString(string: "...", fontSize: 16, color: .white, firstWordColor: nil)
|
|
titleNode.attributedText = NSAttributedString.attributedString(string: "family fall hikes", fontSize: 16, color: .white, firstWordColor: nil)
|
|
}
|
|
|
|
// This is used to expose this function for overriding in extensions
|
|
override public func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
|
|
return ASLayoutSpec()
|
|
}
|
|
|
|
public func show() {
|
|
display(inRect: CGRect(x: 0, y: 0, width: 120, height: 120))
|
|
}
|
|
}
|