Self Scrollable text inside CAScrollLayer
One hardly needs or wants a CAScrollLayer or a CATextLayer for this. Simply start with a superview that clips to its bounds, and inside that put a UILabel. Animate the sideways movement of the label and you're done.
Here's a rough sketch:
let w1 = self.lab.frame.width
let w2 = self.lab.superview!.frame.width
let w = w1 - w2
let x = self.lab.frame.origin.x
UIView.animateWithDuration(5, delay: 0, options: .CurveLinear, animations: {
self.lab.frame.origin.x -= w
}, completion: {
_ in
self.lab.frame.origin.x = x
})
CATextLayer not scrolling
How are you using contentsRect? It's a unit rectangle coordinates, that is each argument is between zero and one (inclusive).
So if you want to display 50 x 50 sub-rectangle at point 30, 30 you would do
textLayer.contentsRect = CGRectMake(30.0f / CONTENT_WIDTH, 30.0f / CONTENT_HEIGHT, 267.0f / CONTENT_WIDTH, 320.0f / CONTENT_HEIGHT);
Where CONTENT_WIDTH and CONTENT_HEIGHT are the size of the contents.
Mix CATextLayer and CAScrollLayer
CALayer (and CATextLayer) can be scrolled
How to use MarqueeLabel in Swift?
I used this little piece of code for my label to scroll like marquee:
@IBOutlet weak var firstLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
UIView.animateWithDuration(12.0, delay: 1, options: ([.CurveLinear, .Repeat]), animations: {() -> Void in
self.firstLabel.center = CGPointMake(0 - self.firstLabel.bounds.size.width / 2, self.firstLabel.center.y)
}, completion: { _ in })
}
Yes, it worked.
Scroll NSTableView to endOfDocument not the last row
Your scrollRowToVisible
approach should work. Here's a quick sample project that implements variable heights with a button that scrolls to the last row. That last row is fully visible after scrolling.
Update:
For table cells larger than the surrounding NSClipView, the above technique will only scroll to the top of the cell. To scroll to the bottom of the last cell, you can use:
let point = NSPoint(x: 0, y: tableView.frame.height)
tableView.scroll(point)
or since OP was in ObjC:
[[self tableView] scrollPoint: NSMakePoint(0, [self tableView].frame.size.height)]
Related Topics
How to Fetch User's Email Using Facebook
Over the Air (Ota) iOS IPA File Distribution for Public
How to Set Image as a Title to Uinavigationbar
Using iOS Gamekit's "Bluetooth Bonjour" with Other Platforms
Swift - Segmented Control - Switch Multiple Views
How to Load Custom Cell ( Xib) in Uicollectionview Cell Using Swift
Bsxpcmessage Received Error for Message: Connection Interrupted
How to Detect Tableview Cell Touched or Clicked in Swift
Why the Extension Is "Momd" But Not "Xcdatamodel" When Search the Path for the Model File
How to Add Done Button on Keyboard on Top of Keyboard in iOS
Enterprise Deployment Certificate and Profiles
Install .Ipa to iPad with or Without Itunes
Differencebetween the App Id and the Bundle Id? Where Is the App Id in the Xcode Project
Alternative Ways to Push View Controllers with Storyboard Programmatically
iOS 9 - "Attempt to Delete and Reload the Same Index Path"