Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FSPagerViewCell.swift #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions Sources/FSPagerViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import UIKit
open class FSPagerViewCell: UICollectionViewCell {

/// Returns the label used for the main textual content of the pager view cell.
open var labelHeight: CGFloat = 0.0
open var pageControlWidth: CGFloat = 0.0
open var textLabel: UILabel? {
if let _ = _textLabel {
return _textLabel
Expand Down Expand Up @@ -99,10 +101,10 @@ open class FSPagerViewCell: UICollectionViewCell {
fileprivate func commonInit() {
self.contentView.backgroundColor = UIColor.clear
self.backgroundColor = UIColor.clear
self.contentView.layer.shadowColor = UIColor.black.cgColor
self.contentView.layer.shadowRadius = 5
self.contentView.layer.shadowOpacity = 0.75
self.contentView.layer.shadowOffset = .zero
//self.contentView.layer.shadowColor = UIColor.black.cgColor
//self.contentView.layer.shadowRadius = 5
//self.contentView.layer.shadowOpacity = 0.75
//self.contentView.layer.shadowOffset = .zero
}

deinit {
Expand All @@ -119,14 +121,19 @@ open class FSPagerViewCell: UICollectionViewCell {
if let textLabel = _textLabel {
textLabel.superview!.frame = {
var rect = self.contentView.bounds
let height = textLabel.font.pointSize*1.5
rect.size.height = height
rect.origin.y = self.contentView.frame.height-height
let height = textLabel.font.pointSize * 1.5
if labelHeight < height {
rect.size.height = height
} else {
rect.size.height = labelHeight
}
rect.origin.y = self.contentView.frame.height - rect.size.height
return rect
}()
textLabel.frame = {
var rect = textLabel.superview!.bounds
rect = rect.insetBy(dx: 8, dy: 0)
rect = rect.insetBy(dx: 15, dy: 0)
rect.size.width -= pageControlWidth
rect.size.height -= 1
rect.origin.y += 1
return rect
Expand Down