Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS で CSS スキニング

iOS で CSS スキニング

NUI を使って CSS スキニングしてみたお話

Toshihiro Morimoto

June 22, 2013
Tweet

More Decks by Toshihiro Morimoto

Other Decks in Programming

Transcript

  1. UILabel ͷ৔߹ CGRect frame = CGRectMake(0, 0, 100, 100); UILabel

    *label = [[UILabel alloc] initWithFrame:frame]; label.text = @"NUI demo"; label.font = [UIFont fontWithName:@"Helvetica" size:16]; label.textColor = [UIColor blueColor]; label.shadowColor = [UIColor grayColor]; label.shadowOffset = CGSizeMake(1, 1); label.textAlignment = NSTextAlignmentCenter; label.backgroundColor = [UIColor whiteColor];
  2. UILabel ͷ৔߹ CGRect frame = CGRectMake(0, 0, 100, 100); UILabel

    *label = [[UILabel alloc] initWithFrame:frame]; label.text = @"NUI demo"; // ↓ ͜Ε͔ΒԼ͸ελΠϧ label.font = [UIFont fontWithName:@"Helvetica" size:16]; label.textColor = [UIColor blueColor]; label.shadowColor = [UIColor grayColor]; label.shadowOffset = CGSizeMake(1, 1); label.textAlignment = NSTextAlignmentCenter; label.backgroundColor = [UIColor whiteColor];
  3. NUI ࢖༻ͨ͠ UILabel CGRect frame = CGRectMake(0, 0, 100, 100);

    UILabel *label = [[UILabel alloc] initWithFrame:frame]; label.text = @"NUI demo"; label.nuiClass = @"SampleLabel"; SampleLabel { font-name: Helvetica; font-size: 16 font-color: blue; shadow-color: gray; shadow-offset: 1, 1; text-align: center; background-color: white; } NSSϑΝΠϧ
  4. NUI

  5. NUI • OSS (MIT License) • pading, margin ͸ͳ͍ɻ͋͘·Ͱ૷০ͷΈ •

    version 0.2.5 Ҏ߱͸ iOS6 Ҏ্͕ඞਢ • iOS7 ͸ରԠதͱͷ͜ͱ
  6. Pixate • NUI ΑΓ΋ɺΑΓ CSS ϥΠΫͳࢦఆ • ແྉͰ͔ͭ͑ΔΑ͏ʹͳΓ·ͨ͠ɻ ͨͩ͠ඇӦར໨త͔ͭձࣾͩͱ10໊·Ͱ •

    RubyMotion, Titanium, MonoTouch Ͱ΋ར༻Մೳ • Framework Ͱ഑෍͞ΕΔͷͰϒϥοΫϘοΫε
  7. ϥΠϒϥϦൺֱ • Pixate ͩͱ pading, margin ΛࢦఆͰ͖Δά ϥσʔγϣϯ΋ࡉ͔͘ઃఆͰ͖Δ • NUI

    ͸͋͘·ͰελΠϧͷΈɹɹɹɹɹ Ґஔௐ੔ ͸ࣗྗͰ͕Μ͹Δ ͨͩ͠ Storyboard Λ࢖͏͜ͱͰ ɹ ͦͷลΓͷࠩ͸ຒΊΕΔ
  8. main.m int main(int argc, char *argv[]) { @autoreleasepool { [NUISettings

    initWithStylesheet:@"NSSϑΝΠϧΛࢦఆ͢Δ"]; return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } }
  9. ελΠϧͷॻ͖ํ @primaryFontNameBold: HelveticaNeue-Bold; @primaryFontSize: 17; Button { background-color: red; font-color:

    #FFFFFF; font-color-highlighted: rgb(204, 204, 204) font-name: @primaryFontNameBold; font-size: @primaryFontSize; corner-radius: 6; }
  10. ελΠϧͷॻ͖ํ @primaryFontNameBold: HelveticaNeue-Bold; @primaryFontSize: 17; BlueButton { background-color: blue; font-color:

    #FFFFFF; font-color-highlighted: rgb(204, 204, 204) font-name: @primaryFontNameBold; font-size: @primaryFontSize; corner-radius: 6; }
  11. 2. ಠࣗΫϥεΛఆٛͯ͠ελΠϧΛࢦఆ͢Δ • NSS ϑΝΠϧͰఆٛͯ͠ Storyboard ΋͘͠͸ίʔυͰ nuiClass Λࢦఆ͢Δ •

    ΠϯελϯεຖʹελΠϧΛࢦఆ͢Δ • ελΠϧͷܧঝͰ͖Δ (ྫ) nuiClass=@”Label:TitleLabel”
  12. ίʔυͰελΠϧΛࢦఆ CGRect frame = CGRectMake(0, 0, 100, 100); UILabel *label

    = [[UILabel alloc] initWithFrame:frame]; label.nuiClass = @"titleLabel"; [self.view addSubview:label];
  13. ίʔυͰελΠϧΛࢦఆ CGRect frame = CGRectMake(0, 0, 100, 100); UILabel *label

    = [[UILabel alloc] initWithFrame:frame]; label.nuiClass = @"titleLabel"; [self.view addSubview:label]; CGRect frame = CGRectMake(0, 0, 100, 100); UILabel *label = [[UILabel alloc] initWithFrame:frame]; [NUIRenderer renderLabel:label withClass:@"titleLabel"]; [self.view addSubview:label];
  14. ...