Giter Club home page Giter Club logo

material-components-ios's Introduction

Material Components for iOS

Material Components for iOS (MDC-iOS) helps developers execute Material Design. Developed by a core team of engineers and UX designers at Google, these components enable a reliable development workflow to build beautiful and functional iOS apps. Learn more about how Material Design supports design and usability best practices across platforms in the Material Design Platform Adaptation guidelines.

Material Components for iOS are written in Objective-C and support Swift and Interface Builder.

Useful Links

Trying out Material Components

Our catalog showcases Material Components. You can use the pod try command from anywhere on your machine to try the components, even if you haven't checked out the repo yet:

pod try MaterialComponents

In case you have already checked out the repo, run the following command:

pod install --project-directory=catalog/

Installation

Getting Started with a New Project

Check out our tutorial for a step-by-step guide to setting up a new project using Material Components.

Adding Material Components to an Existing Project

CocoaPods is the easiest way to get started (if you're new to CocoaPods, check out their getting started documentation.)

To install CocoaPods, run the following commands:

sudo gem install cocoapods

To integrate Material Components in your existing application, first create a new Podfile:

cd your-project-directory
pod init

Next, add the Material Components for iOS pod to your target in your Podfile:

target "MyApp" do
  ...
  # Until Material Components for iOS is public:
  pod 'MaterialComponents', :git => 'https://github.com/material-components/material-components-ios.git'

  # After Material Components for iOS is public:
  # pod 'MaterialComponents'
end

If you are using Swift, don’t forget to uncomment the use_frameworks! line at the top of your Podfile.

Then run the command:

pod install

Now you're ready to get started in Xcode. Don't forget to open the workspace Cocoapods created for you instead of the original project:

open your-project.xcworkspace

Usage

The components are built upon familiar UIKit classes and can be added to a view with just a couple of lines. Simply import the Material Components header for the component you're interested in, and add it to your view.

Swift

import MaterialComponents.MaterialButtons

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let raiseButton = MDCRaisedButton.init();
        raiseButton.setTitle("Raised Button", forState: .Normal);
        raiseButton.sizeToFit();
        raiseButton.addTarget(self, action: #selector(tapped), forControlEvents: .TouchUpInside);
        self.view.addSubview(raiseButton);
    }

    func tapped(sender: UIButton!){
        NSLog("Button was tapped!");
    }

}

Objective-C

#import "MaterialButtons.h"

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  MDCRaisedButton *raisedButton = [MDCRaisedButton new];
  [raisedButton setTitle:@"Raised Button" forState:UIControlStateNormal];
  [raisedButton sizeToFit];
  [raisedButton addTarget:self
                   action:@selector(tapped:)
         forControlEvents:UIControlEventTouchUpInside];

  [self.view addSubview:raisedButton];
}

- (void)tapped:(id)sender {
  NSLog(@"Button was tapped!");
}

@end

Attributions

Material Components for iOS uses Material Design icons, copyright Google Inc. and licensed under CC BY 4.0.

Several components use MDFTextAccessibility, copyright Google Inc. and licensed under Apache 2.0 without a NOTICE file.

MDCCatalog uses the Roboto font, copyright 2011 Google Inc. and licensed under Apache 2.0 without a NOTICE file.

material-components-ios's People

Contributors

ajsecord avatar arcank avatar brianjmoore avatar cezarc1 avatar chriscox avatar chuckhays avatar dcouturier avatar edx246 avatar eli8527 avatar eshiehz avatar gambard avatar ianegordon avatar jgunaratne avatar jmstriegel avatar jverkoey avatar jyquinn avatar jzting avatar katykasmai avatar keefertaylor avatar liquidx avatar peterfriese avatar randallli avatar rsheeter avatar samnm avatar sdefresne avatar seanoshea avatar shepjgoogle avatar traviskaufman avatar willlarche avatar yeelan0319 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.