Skip to content

Instantly share code, notes, and snippets.

// アスペクト比は固定
self.imageCropViewController.cropMode = YMNImageCropModeFixedAspect;
// アスペクト比の値は1.f
self.imageCropViewController.cropRectAspectRatio = 1.f;
@yoshimin
yoshimin / gist:1a26147f8c81e0e389fb
Created August 24, 2014 09:12
YMNImageCropMode
/// クロップの枠の拡縮の仕方
typedef NS_ENUM(NSUInteger, YMNImageCropMode) {
/// 枠のアスペクト比は自由
YMNImageCropModeFlexible,
/// 枠のアスペクト比は固定
YMNImageCropModeFixedAspect
};
@yoshimin
yoshimin / gist:e5bbb1d57285e9fd146f
Created August 24, 2014 09:11
delegateで画像が返される
- (void)imageCropViewController:(UIViewController* )controller didFinishCroppingImage:(UIImage *)image
{
//ここでimageを受け取る
}
@yoshimin
yoshimin / gist:82a31fc1f3d3f2a4c325
Created August 24, 2014 09:08
YMNImageCropViewControllerのインスタンスを生成
self.imageCropViewController = [[YMNImageCropViewController alloc] initWithImage:image];
self.imageCropViewController.delegate = self;
[self presentViewController:self.imageCropViewController animated:NO completion:nil];
@yoshimin
yoshimin / gist:858d14751fc1c00807d2
Created August 10, 2014 17:06
NSAttributedStringを使ってリンク文字を作る
#import "YMNViewController.h"
NSString *const Text = @"The iOS Developer Program provides a complete and integrated process for developing and distributing iOS apps on the App Store. Learn more";
NSString *const LinkText = @"Learn more";
@interface YMNViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) UITapGestureRecognizer *tapGesture;
@yoshimin
yoshimin / gist:81f7cbc22050b7e83e29
Created August 10, 2014 16:09
CoreTextで描画した文字をリンカブルにする(タップされたら文字をハイライトさせる)
#import "YMNCoreTextView.h"
#import <CoreText/CoreText.h>
#import <QuartzCore/QuartzCore.h>
@interface YMNCoreTextView()
@property (nonatomic, strong) NSMutableAttributedString *attributedString;
@property (nonatomic, assign) CTFrameRef drawingFrame;
@property (nonatomic, assign) NSRange linkableWordRange;
@yoshimin
yoshimin / gist:b4ed78b58bbb12c20bf6
Created August 10, 2014 16:01
CoreTextを使って描画した文字をリンカブルにする
#import "YMNCoreTextView.h"
#import <CoreText/CoreText.h>
#import <QuartzCore/QuartzCore.h>
@interface YMNCoreTextView()
@property (nonatomic, strong) NSMutableAttributedString *attributedString;
@property (nonatomic, assign) CTFrameRef drawingFrame;
@property (nonatomic, assign) NSRange linkableWordRange;
@yoshimin
yoshimin / gist:7fc6c8759899583be101
Last active August 29, 2015 14:05
CoreTextを使って特定の文字をリンクっぽい見た目にする
#import "YMNCoreTextView.h"
#import <CoreText/CoreText.h>
#import <QuartzCore/QuartzCore.h>
@interface YMNCoreTextView()
@property (nonatomic, strong) NSMutableAttributedString *attributedString;
@end
@yoshimin
yoshimin / gist:142e359443c8c14eec3a
Created August 10, 2014 08:04
UIViewのサブクラスでCoreTextを使い文字を描画
#import "YMNCoreTextView.h"
#import <CoreText/CoreText.h>
#import <QuartzCore/QuartzCore.h>
@interface YMNCoreTextView()
@property (nonatomic, strong) NSMutableAttributedString *attributedString;
@end
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"places.plist"];
NSArray *array = [NSArray arrayWithContentsOfFile:filePath];
for (NSData *data in [YSPlaceDataManager loadFromPropertyList]) {
// プリパティリストから取り出したNSData型のデータをCustomObject型に再変換
CustomObject *customObj = [NSKeyedUnarchiver unarchiveObjectWithData:data];
NSLog(@"%@", customObj);
}