Skip to content

Instantly share code, notes, and snippets.

@fmtonakai
fmtonakai / AttributedString.swift
Last active August 6, 2023 21:27
AttributedString with String Interpolation
//
// AttributedString.swift
//
// Created by fm.tonakai on 2019/04/08.
//
import UIKit
public struct AttributedString: ExpressibleByStringLiteral, ExpressibleByStringInterpolation, CustomStringConvertible {
public struct StringInterpolation: StringInterpolationProtocol {
@fmtonakai
fmtonakai / UITextViewSubclass.m
Last active August 29, 2015 14:00
TextViewのリンクのところだけ反応させてあとはスルーする
// implementation of UITextView subclass
// editableプロパティをNO, selectableプロパティをYESにする
// リンクのところ以外のタッチを透過する
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
CGPoint p = point;
p.y -= self.textContainerInset.top;
p.x -= self.textContainerInset.left;
NSInteger i = [self.layoutManager characterIndexForPoint:p inTextContainer:self.textContainer fractionOfDistanceBetweenInsertionPoints:NULL];
@fmtonakai
fmtonakai / ViewController.m
Created July 9, 2013 08:13
実際に使ってみる
#import "ViewController.h"
#import "SwitchCell.h"
@interface ViewController () <UITableViewDataSource, UITableViewDelegateSwitchCell>
@end
@implementation ViewController
- (void)viewDidLoad
@fmtonakai
fmtonakai / SwitchCell.h
Created July 9, 2013 08:12
accessoryViewにUISwitchを仕掛けたCell
#import <UIKit/UIKit.h>
// delegate method定義
@protocol UITableViewDelegateSwitchCell <UITableViewDelegate>
@optional
-(void)tableView:(UITableView *)tableView didChangeValue:(BOOL)value forRowWithIndexPath:(NSIndexPath *)indexPath;
@end
@interface SwitchCell : UITableViewCell
@fmtonakai
fmtonakai / UITableViewCell+IndexPath.h
Created July 9, 2013 07:52
UITableViewCellのカテゴリ
#import <UIKit/UIKit.h>
@interface UITableViewCell (IndexPath)
-(UITableView *)tableView;
-(NSIndexPath *)indexPath;
@end
typedef id (^ActivitySourceWrapperExecuteBlock)(UIActivityViewController* activityViewController,NSString* activityType);
@interface ActivitySourceWrapper : NSObject<UIActivityItemSource>
@property id placeholder;
-(id)initWithBlock:(ActivitySourceWrapperExecuteBlock)block;
-(id)initWithBlock:(ActivitySourceWrapperExecuteBlock)block withPlaceholder:(id)placeholder;
@end
@fmtonakai
fmtonakai / gist:5106889
Created March 7, 2013 09:56
UIActivityViewControllerでTwitterの時だけハッシュタグをつける実装呼び出し
- (IBAction)share:(id)sender
{
ActivityText *text = [[ActivityText alloc] initWithText:@"本文はこちらです。" hashTag:@"ハッシュタグ"];
UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:@[text] applicationActivities:nil];
[self presentViewController:avc animated:YES completion:nil];
}
@fmtonakai
fmtonakai / gist:5106823
Last active December 14, 2015 15:19
普通にUIActivityViewControllerで共有する場合
-(void)openActivityController
{
NSString *text = @"本文はこちらです。 #ハッシュタグ";
UIActivityViewController *avc = [[UIActivityViewController alloc] initWithActivityItems:@[text] applicationActivities:nil];
[self presentViewController:avc animated:YES completion:nil];
}
@fmtonakai
fmtonakai / ActivityText.h
Last active December 14, 2015 15:19
UIActivityViewControllerでTwitterの時だけハッシュタグを追加する
#import <Foundation/Foundation.h>
@interface ActivityText : NSObject <UIActivityItemSource>
-(id)initWithText:(NSString *)text hashTag:(NSString *)hashTag;
@end
@fmtonakai
fmtonakai / UIImage+Blur.h
Created November 26, 2012 02:59
UIImage Blur
//
// UIImage+Blur.h
// HTTPLoaderTest
//
// Created by masaki.fuke on 12/08/14.
// Copyright (c) 2012年 masaki.fuke. All rights reserved.
//
#import <UIKit/UIKit.h>