LoginSignup
13
12

More than 5 years have passed since last update.

iOS プロトタイピング - Masu

Posted at

UI 設計をする際、各パーツのサイズや配置で悩むことが多々あり、そんな悩みを UIView と分かち合うためのプレースホルダもどき。

midnightSuyama/Masu

インストール

CocoaPods でどうぞ。

pod "Masu"

使用方法

Storyboard

UIView の Custom ClassMasu の四文字を入力するだけ。
ラベル表記を望むなら、User Defined Runtime Attributestext に String を添えて。

storyboard.png

Code

UIView

普通に View として利用。

Masu *masu = [[Masu alloc] initWithFrame:CGRectMake(0, 300.0f, 220.0f, 100.0f)];
masu.backgroundColor = [UIColor colorWithRed:0 green:0.5f blue:0.5f alpha:1];
masu.text            = @"View";
[self.view addSubview:masu];

UIImage

UIButton などの画像として扱いたいとき。

UIImage *image = [Masu imageWithSize:btn.frame.size backgroundColor:[UIColor grayColor] labelText:@"Button"];

Category

既存の View に適用したいとき。

[view showMasu];

category.png

テスト

CocoaPods のテンプレート準拠で、Specta, Expecta, FBSnapshotTestCase を利用。
ビューテストのためのマッチャとして、Expecta Matchers for FBSnapshotTestCase
も用意されているので、

expect(masu).to.recordSnapshot();

でスナップショット作って、

expect(masu).to.haveValidSnapshot();

で判定するだけの簡単なお仕事です。

13
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
12