This file contains 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 Foundation | |
import UIKit | |
extension UIView { | |
func constraintForAttribute(attribute:NSLayoutAttribute) -> NSLayoutConstraint? { | |
for constraint in self.constraints { | |
if constraint.firstAttribute == attribute { | |
return constraint | |
} |
This file contains 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
public extension UITableView { | |
func registerClass(myClass:AnyClass) { | |
let bundle = NSBundle(forClass: myClass) | |
self.registerNib(UINib(nibName: String(myClass), bundle: bundle), forCellReuseIdentifier: String(myClass)) | |
} | |
func dequeue<T where T:UITableViewCell>(myclass:T.Type) -> T { | |
return self.dequeueReusableCellWithIdentifier(String(myclass)) as! T | |
} |
This file contains 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
extension UIColor { | |
class func HTSDColorWithHexString (hex:String) -> UIColor { | |
var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString | |
if (cString.hasPrefix("#")) { | |
cString = (cString as NSString).substringFromIndex(1) | |
} | |
if (cString.characters.count != 6) { |
This file contains 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
func printFonts() { | |
let fontFamilyNames = UIFont.familyNames() | |
for familyName in fontFamilyNames { | |
print("------------------------------") | |
print("Font Family Name = [\(familyName)]") | |
let names = UIFont.fontNamesForFamilyName(familyName) | |
print("Font Names = [\(names)]") | |
} | |
} |
This file contains 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 UICollectionView { | |
func registerCell(cellType:UICollectionViewCell.Type) { | |
self.registerNib(cellType.nib(), forCellWithReuseIdentifier: cellType.id()) | |
} | |
func registerSupplementaryView(classType:UICollectionReusableView.Type, kind:String) { | |
self.registerNib(classType.nib(), forSupplementaryViewOfKind: kind, withReuseIdentifier: classType.id()) |
This file contains 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 | |
import SystemConfiguration | |
public let ReachabilityChangedNotification = "ReachabilityChangedNotification" | |
class HTSDReachabiltiy: NSObject { | |
typealias NetworkReachable = (HTSDReachabiltiy) -> () | |
typealias NetworkUnreachable = (HTSDReachabiltiy) -> () | |
enum NetworkStatus: CustomStringConvertible { |
This file contains 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
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; | |
} | |
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone; | |
} |
This file contains 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
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ | |
[tableView cellForRowAtIndexPath:[NSIndexPath indexPathForItem:indexPath.row inSection:indexPath.section]].accessoryType = UITableViewCellAccessoryCheckmark; | |
[self deSelectOtherCellsInTableView:tableView Except:indexPath]; | |
} | |
-(void)deSelectOtherCellsInTableView:(UITableView *)tableView Except:(NSIndexPath *)indexPath{ | |
for(UITableViewCell *cell in [tableView visibleCells]){ | |
NSIndexPath *index = [tableView indexPathForCell:cell]; | |
if(index.section == indexPath.section && index.row != indexPath.row){ |
This file contains 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 <QuartzCore/QuartzCore.h> | |
UIImageView * roundedView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"wood.jpg"]]; | |
// Get the Layer of any view | |
CALayer * l = [roundedView layer]; | |
[l setMasksToBounds:YES]; | |
[l setCornerRadius:10.0]; | |
// You can even add a border | |
[l setBorderWidth:4.0]; |
This file contains 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
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section | |
{ | |
UIView *view = [[UIView alloc ]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 18)]; | |
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, tableView.frame.size.width, 18)]; | |
[label setFont:[UIFont boldSystemFontOfSize:12]]; | |
NSString *string =@"Enter Email Address"; | |
/* Section header is in 0th index... */ | |
[label setText:string]; | |
view.backgroundColor = [UIColor clearColor]; |
NewerOlder