Skip to content

Commit

Permalink
README and similar updates. Note Carthage & Cocoapods compatibility a…
Browse files Browse the repository at this point in the history
…pproach for frameworks. [common]
  • Loading branch information
cbpowell committed Jun 8, 2017
1 parent af5ec76 commit 8d2de40
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011-2016 Charles Powell
Copyright (c) 2011-2017 Charles Powell

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
Expand Down
File renamed without changes
Binary file added Metadata/carthage_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 25 additions & 2 deletions README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MarqueeLabel is a UILabel subclass adds a scrolling marquee effect when the text
MarqueeLabel is compatible with both iOS and tvOS, and currently works with Swift 3.0 and the iOS 10.0 SDK! (But if you're looking for Swift 2.x compatibility, [you can use release 2.8](https://github.com/cbpowell/MarqueeLabel/releases/tag/2.8.0))

## Check it out!
![GIF of MarqueeLabelDemo in action](https://raw.githubusercontent.com/cbpowell/MarqueeLabel/master/MarqueeLabelDemo.gif)
![GIF of MarqueeLabelDemo in action](https://raw.githubusercontent.com/cbpowell/MarqueeLabel/master/Metadata/MarqueeLabelDemo.gif)

## How To Get Started

Expand Down Expand Up @@ -43,6 +43,11 @@ github "cbpowell/MarqueeLabel"
2. Add **QuartzCore.framework** to your project frameworks.
3. Import MarqueeLabel and replace your UILabels with MarqueeLabels as needed.


#### Using MarqueeLabel in your own Swift Framework?

See the [Special Note below](https://github.com/cbpowell/MarqueeLabel/blob/master/README.mdown#swiftframeworkusage) on supporting Cocoapods and Carthage simultaneously in a Swift framework!

## Usage

MarqueeLabel automatically scrolls its text, at either a defined rate (points per second) or over a duration (seconds), whenever the length of the label's text exceeds the space available given the label's frame.
Expand Down Expand Up @@ -127,7 +132,7 @@ Usually you'll configure the MarqueeLabel instance when building the cell in `ta

To make sure the scrolling animation _does_ begin as the cell scrolls onscreen, you can use the the `restartLabel` method on your MarqueeLabels inside the `tableView:willDisplayCell:forRowAtIndexPath:` delegate method (or similar for UICollectionView).

**That said** - the UITableView/UICollectionView best practice is to minimize things like excessive animation, subviews, and custom drawing in your cells, in order to get glassy smooth scrolling. In general I would recommend against allowing your labels to automatically animate during user scrolling of the UITableView/UICollectionView. I suggest [holding scrolling](http://cocoadocs.org/docsets/MarqueeLabel/2.0.7/Classes/MarqueeLabel.html#//api/name/holdScrolling) or [labelizing](http://cocoadocs.org/docsets/MarqueeLabel/2.0.7/Classes/MarqueeLabel.html#//api/name/labelize) the labels while the user scrolls. See the table view example in the demo!
**That said** - the UITableView/UICollectionView best practice is to minimize things like excessive animation, subviews, and custom drawing in your cells, in order to get glassy smooth scrolling. In general I would recommend against allowing your labels to automatically animate during user scrolling of the UITableView/UICollectionView. I suggest [holding scrolling](http://cocoadocs.org/docsets/MarqueeLabel/3.0.3/Classes/MarqueeLabel.html#//api/name/holdScrolling) or [labelizing](http://cocoadocs.org/docsets/MarqueeLabel/3.0.3/Classes/MarqueeLabel.html#//api/name/labelize) the labels while the user scrolls. See the table view example in the demo!


#### Important Animation Note<a id="importantanimationnote"></a>
Expand All @@ -137,6 +142,24 @@ To address this, MarqueeLabel provides a few class methods that allow easy "rest

`controllerLabelsShouldLabelize:` and `controllerLabelsShouldAnimate:` are for convenience, allowing labelizing and re-animating all labels of a UIViewController. Labelizing can be useful for performance, such as labelizing all MarqueeLabels when a UITableView/UIScrollView starts scrolling.

#### Using MarqueeLabel as a dependency with Cocoapods and Carthage - Swift only!<a id="swiftframeworkusage"></a>

If you're developing your own Swift framework that uses MarqueeLabel as a dependency, and want to support both Cocoapods _and_ Carthage, you may need to do a little extra work. Because of the current naming of MarqueeLabel frameworks (and Carthage building all targets in the project), the name of Swift dynamic framework to import varies between Cocoapods and Carthage.

When building the Swift subspec with Cocoapods, MarqueeLabel is imported with `import MarqueeLabel`. However, because Carthage requires distinct names for each target, when building with Carthage the import statement for the Swift target is `import MarqueeLabelSwift`.

A suggested workaround is to use a [conditional compilation block](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/doc/uid/TP40014097-CH33-ID538)(aka preprocessor macro) to switch between the two import statements based on whether or not the target is intended for use with Carthage. To specify the target, you can add an "Other Swift Flag" in the Swift Compiler - Custom Flags section of your Carthage target (i.e. the framework) build settings:
![Carthage Build Settings](https://raw.githubusercontent.com/cbpowell/MarqueeLabel/master/Metadata/carthage_config.png)
And then include the following conditional compilation statement to use the appropriate framework name:
```swift
#if CARTHAGE_CONFIG
import MarqueeLabelSwift //Carthage build name
#else
import MarqueeLabel // Cocoapods build name
#endif
```


## Todo
- Ideas?

Expand Down

0 comments on commit 8d2de40

Please sign in to comment.