Skip to content

Instantly share code, notes, and snippets.

View magneticrob's full-sized avatar

magneticrob magneticrob

View GitHub Profile
@magneticrob
magneticrob / ParallaxGroupedSectionHeaderTableView
Created February 25, 2019 13:20
Fix for ParallaxHeader grouped section headers appearing over the header, after cell recycling
public class ParallaxGroupedSectionHeaderTableView: UITableView {
override public func layoutSubviews() {
super.layoutSubviews()
layoutHeaderViews()
}
private func layoutHeaderViews() {
for index in 0 ..< numberOfSections {
guard let sectionView = headerView(forSection: index) else { continue }
if let newFrame = UIApplication.shared.keyWindow?.bounds {
// Remove autoresizing constraints
self.view.translatesAutoresizingMaskIntoConstraints = false
// Add width constraint
self.view.addConstraint(NSLayoutConstraint.init(item: self.view, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: SideMenuManager.menuWidth))
// Add height constraint
self.view.addConstraint(NSLayoutConstraint.init(item: self.view, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: newFrame.size.height))
}
@magneticrob
magneticrob / Reduce File Size 50%.qfilter
Last active November 4, 2016 11:08
Quartz Filter for reducing PDFs without butchering them. Drop into /Library/Filters and it'll appear in Preview
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Domains</key>
<dict>
<key>Applications</key>
<true/>
<key>Printing</key>
<true/>
- (NSArray *)inbetweenRangesForArrayOfRanges:(NSArray *)arrayOfRanges forString:(NSString *)string
{
NSMutableArray *ranges = @[].mutableCopy;
for (int i = 0; i < arrayOfRanges.count; i++)
{
// grab the first range
NSRange currentRange = [arrayOfRanges[i] rangeValue];
// add it to our return object