This file contains hidden or 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
import UIKit | |
extension UIView { | |
public func prepareForAutolayout() { | |
translatesAutoresizingMaskIntoConstraints = false | |
} | |
public func autopin(constant: CGFloat = 0) { | |
autopin(.top, constant: constant) |
This file contains hidden or 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
import CoreLocation | |
enum LocationAuthorizationStatus { | |
case always | |
case whenInUse | |
} | |
final class LocationManager: NSObject, CLLocationManagerDelegate { | |
typealias LocationAuthorizationCompletion = (CLAuthorizationStatus) -> Void |
This file contains hidden or 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
class CenterCellCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { | |
guard let collectionView = self.collectionView else { | |
return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity) | |
} | |
if collectionView.numberOfItems(inSection: 0) == 0 { | |
return super.targetContentOffset(forProposedContentOffset: proposedContentOffset) | |
} |
This file contains hidden or 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
http://stackoverflow.com/questions/24912704/xcodebuild-running-tests-headless | |
http://stackoverflow.com/questions/9476131/is-there-a-way-to-remove-the-authorization-prompt-from-command-line-instances-of |
This file contains hidden or 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
<h1>ARGB color to Objective-C UIColor</h1><br> | |
<div id="input-bar"> | |
<div id="hexBar"> | |
<input type="text" id="argbText"></input> | |
</div> | |
<div id="button"> | |
<input type="button" id="convertButton" value="Convert" onclick="argb2UIColor()"></input> | |
</div> | |
</div> | |
<div id="output-bar"> |
This file contains hidden or 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
http://charlesharley.com/2013/programming/uibutton-in-uitableviewcell-has-no-highlight-state/ | |
I recently created a custom UITableViewCell with a UIButton as a subview. Pretty standard except that the highlight state of the button was only activated if you held your finger on the button for more than some fraction of a second. The solution is quite straight forward but is subtle enough to justify a quick blog post. | |
Table view cells are displayed using a UITableView which is a subclass of UIScrollView and as such inherits the ability to scroll. A scroll view intercepts touch events and has a short delay to check if the touch event is part of a scroll gesture. If it isn’t then the touch event is passed onto the corresponding view. That explains the delay in the button highlight state. | |
We can remove the delay by setting UIScrollView.delaysContentTouches = NO. A side effect of this change is that scroll gestures cannot start from the buttons. Depending on how big your buttons are this might not be ideal. The wo |
This file contains hidden or 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
@interface PassthroughView : UIView | |
@end | |
@implementation PassthroughView | |
-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { | |
for (UIView *view in self.subviews) { | |
if (!view.hidden && view.alpha > 0 && view.userInteractionEnabled && [view pointInside:[self convertPoint:point toView:view] withEvent:event]) | |
return YES; | |
} | |
return NO; |
This file contains hidden or 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
+ (NSArray *)splitArrayIntoHalf:(NSArray *)originalData { | |
NSRange firstHalfRange; | |
firstHalfRange.location = 0; | |
firstHalfRange.length = originalData.count / 2; | |
NSArray *firstHalfArray = [originalData subarrayWithRange:firstHalfRange]; | |
NSRange secondHalfRange; | |
secondHalfRange.location = firstHalfRange.length; |
NewerOlder