-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kahayash
authored and
kahayash
committed
Jul 15, 2017
1 parent
21269ee
commit f270ec1
Showing
5 changed files
with
333 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// TagMenuCell.swift | ||
// iOS Sample | ||
// | ||
// Created by kahayash on 2017/07/15. | ||
// Copyright © 2017年 Kazuhiro Hayashi. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
import PagingKit | ||
|
||
class TagMenuCell: PagingMenuCell { | ||
static let sizingCell = UINib(nibName: "TagMenuCell", bundle: nil).instantiate(withOwner: self, options: nil).first as! TagMenuCell | ||
|
||
@IBOutlet weak var contentViewTopConstraint: NSLayoutConstraint! | ||
@IBOutlet weak var titieLabel: UILabel! | ||
@IBOutlet weak var contentView: UIView! | ||
|
||
func focus(percent: CGFloat, animated: Bool = false) { | ||
contentViewTopConstraint.constant = 6 * (1 - percent) + 2 | ||
if animated { | ||
UIView.perform( | ||
.delete, | ||
on: [], | ||
options: UIViewAnimationOptions(rawValue: 0), | ||
animations: { [weak self] in | ||
self?.contentView.setNeedsLayout() | ||
self?.contentView.layoutIfNeeded() | ||
}, | ||
completion: { (finish) in } | ||
) | ||
} | ||
} | ||
|
||
override func draw(_ rect: CGRect) { | ||
super.draw(rect) | ||
|
||
let path = UIBezierPath( | ||
roundedRect: rect, | ||
byRoundingCorners: [.topLeft, .topRight], | ||
cornerRadii: CGSize(width: 6, height: 6) | ||
) | ||
let shapeLayer = CAShapeLayer() | ||
shapeLayer.frame = contentView.bounds | ||
shapeLayer.path = path.cgPath | ||
contentView.layer.mask = shapeLayer | ||
} | ||
} |
Oops, something went wrong.