• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

twho/material-design-widgets-lite-ios: Material design styled buttons, verticall ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

twho/material-design-widgets-lite-ios

开源软件地址(OpenSource Url):

https://github.com/twho/material-design-widgets-lite-ios

开源编程语言(OpenSource Language):

Swift 93.1%

开源软件介绍(OpenSource Introduction):

Material Design Widgets - Lightweight

This framework give you full flexibility to apply any material design widget you would like to use in your app! Please see below steps if you only need to use one or two of the entire package widgets.

Generic badge Generic badge Generic badge Generic badge Generic badge

Light mode Dark mode
Overview Overview Dark

You may download MaterialDesignWidgetsDemo to see how its used in your app.

Key Features

  • A full package of material design widgets that you'll need to upgrade your app's visual.
  • Widget classes are made to be open, which gives you flexibility to create your own.
  • Instead of pull down the entire package, you can also copy the source of any widget you need independently.
  • If you decide to just use one of the widgets, you can follow below usage for instructions on which files you need for that specific widget.
  • We support storyboard! Check demo project for more implementation details.

Requirements

  • Swift 5.0
  • iOS 11.0+

Installation

MaterialDesignWidgets is available through CocoaPods. To install it, simply add the following line to your Podfile:

$ pod 'MaterialDesignWidgets'

If you don't use CocoaPods, you can download the entire project then drag and drop all the classes and use them in your project.

Usage

Buttons

Required Files:

  • RippleLayer.swift
  • MaterialButton.swift

Normal Button

let btnSample1 = MaterialButton(text: "Sample1", cornerRadius: 15.0)
let btnSample2 = MaterialButton(text: "Sample2", textColor: .black, bgColor: .white)
Light mode Dark mode
Button Button Dark

Loading Button

let btnLoading = MaterialButton(text: "Loading Button", cornerRadius: 15.0)
loadingBtn.addTarget(self, action: #selector(tapLoadingButton(sender:)), for: .touchUpInside)

@objc func tapLoadingButton(sender: MaterialButton) {
    sender.isLoading = !sender.isLoading
    sender.isLoading ? sender.showLoader(userInteraction: true) : sender.hideLoader()
}
Light mode Dark mode
Loading Button Loading Button Dark

Shadow Button

let btnShadow = MaterialButton(text: "Shadow Button", cornerRadius: 15.0, withShadow: true)
Light mode Dark mode
Shadow Button Shadow Button Dark

Vertical Aligned Button

let img = UIImage(named: "Your image name")
let btnV = MaterialVerticalButton(icon: img, title: "Fill", foregroundColor: .black, bgColor: .white)
Light mode Dark mode
Vertical Aligned Button Vertical Aligned Button Dark

Segmented Control

Required File - MaterialSegmentedControl.swift

Filled

let sgFilled = MaterialSegmentedControl(selectorStyle: .fill, fgColor: .black, selectedFgColor: .white, selectorColor: .black, bgColor: .lightGray)
// Below is styling, you can write your own.
sgFilled.backgroundColor = .lightGray
sgFilled.setCornerBorder(cornerRadius: 18.0)
Light mode Dark mode
Segmented Control Filled Segmented Control Filled Dark

Outline

let sgOutline = MaterialSegmentedControl(selectorStyle: .outline, fgColor: .black, selectedFgColor: .black, selectorColor: .black, bgColor: .white)
Light mode Dark mode
Segmented Control Outline Segmented Control Outline Dark

Line Text

let sgLine = MaterialSegmentedControl(selectorStyle: .line, fgColor: .black, selectedFgColor: .black, selectorColor: .black, bgColor: .white)
Light mode Dark mode
Segmented Control Line Text Segmented Control Line Text Dark

Line Icon

let sgLineIcon = MaterialSegmentedControl(selectorStyle: .line, fgColor: .black, selectedFgColor: .black, selectorColor: .gray, bgColor: .white)
Light mode Dark mode
Segmented Control Line Icon Segmented Control Line Icon Dark

Append Normal Segment

for i in 0..<3 {
    segCtrl.appendSegment(text: "Segment \(i)", textColor: .gray, bgColor: .clear, cornerRadius: radius)
}

Append Icon Segment

let icons = [yourImage1, yourImage2, yourImage3]
for i in 0..<3 {
    sgLineIcon.appendIconSegment(icon: icons[i], preserveIconColor: true, rippleColor: .clear, cornerRadius: 0.0)
}

Add Value Change Listener

segCtrl.addTarget(self, action: #selector(yourSegmentedControlValueChangeMethod), for: .valueChanged)

TextField

Required files:

  • RippleLayer.swift
  • MaterialTextField.swift
let textField = MaterialTextField(hint: "TextField", textColor: .black, bgColor: .white)
Light mode Dark mode
TextField TextField Dark

Loading Indicator

Required file - MaterialLoadingIndicator.swift

let indicatorBlack = MaterialLoadingIndicator(radius: 15.0, color: .black)
indicatorBlack.startAnimating()
let indicatorGray = MaterialLoadingIndicator(radius: 15.0, color: .gray)
indicatorGray.startAnimating()
Light mode Dark mode
Loading Indicator Loading Indicator

Storyboard Usage

Use Material Button as an example

Steps

  1. Create a UIButton in your storyboard.
  2. In Identity inspector tab, set the Class to MaterialButton and Module to MaterialDesignWidgets.

Storyboard class and module configuration

  1. In Attributes inspector tab, set the attributes that are specific to Material Button.

Storyboard class and module configuration

  1. Run your app to see if those attributes are applied!

Credits




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap