Skip to content

Instantly share code, notes, and snippets.

View ferbass's full-sized avatar
:octocat:
ι(`ロ´)ノ

Fernando Bass ferbass

:octocat:
ι(`ロ´)ノ
View GitHub Profile
label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveUIContentSizeCategoryDidChangeNotification:)
name:UIContentSizeCategoryDidChangeNotification object:nil];
- (void)didReceiveUIContentSizeCategoryDidChangeNotification:(NSNotification *)notification
{
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
}
NSNotificationCenter.defaultCenter().addObserver(self,
selector: "didReceiveUIContentSizeCategoryDidChangeNotification:",
name: UIContentSizeCategoryDidChangeNotification, object: nil)
func didReceiveUIContentSizeCategoryDidChangeNotification(notification: NSNotification)
{
label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
}
UIFontDescriptor *descriptorFontBody = [UIFontDescriptor preferredFontDescriptorWithTextStyle:UIFontTextStyleHeadline];
CGFloat descriptorFontBodySize = [userHeadLineFont pointSize];
UIFont *bodyFont = [UIFont fontWithName:@"Zapfino" size:descriptorFontBodySize];
label.font = bodyFont;
let descriptorFontBody = UIFontDescriptor.preferredFontDescriptorWithTextStyle(UIFontTextStyleBody)
let descriptionFontBodySize = descriptorFontBody.pointSize;
let bodyFont = UIFont(name: "Zapfino", size: descriptionFontBodySize)
label.font = bodyFont;
@ferbass
ferbass / rounded button.swift
Last active April 26, 2016 03:38
Rounded Button in Swift
import UIKit
class RoundedButton: UIButton {
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
override func drawRect(rect: CGRect) {
let maskPath = UIBezierPath.init(roundedRect: self.bounds, cornerRadius: 5)
UIColor.clearColor().setFill()
maskPath.fill()
@ferbass
ferbass / button.swift
Created May 3, 2016 04:14
Adding a closure as target to a UIButton
import UIKit
extension UIButton {
private func actionHandleBlock(action:(() -> Void)? = nil) {
struct __ {
static var action :(() -> Void)?
}
if action != nil {
NSMutableArray *commands = [[NSMutableArray alloc] init];
NSString *characters = @"`1234567890-=qwertyuiop[]asdfghjkl;'zxcvbnm,./";
for (NSInteger i = 0; i < characters.length; i++) {
NSString *input = [characters substringWithRange:NSMakeRange(i, 1)];
/* Caps Lock */
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierAlphaShift action:@selector(handleCommand:)]];
/* Shift */
[commands addObject:[UIKeyCommand keyCommandWithInput:input modifierFlags:UIKeyModifierShift action:@selector(handleCommand:)]];
/* Control */