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

richzertuche/ZMaterialDesignUIButton: Swift Material Design UIButton

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

开源软件名称(OpenSource Name):

richzertuche/ZMaterialDesignUIButton

开源软件地址(OpenSource Url):

https://github.com/richzertuche/ZMaterialDesignUIButton

开源编程语言(OpenSource Language):

Swift 52.6%

开源软件介绍(OpenSource Introduction):

ZMaterialDesignUIButton

Swift and Objective-C Animated Material Design UIButton

This Swift and Objective-C! UIButton was made inspired in Google new Material Design, and this GIF :]


[![ZMaterialButton](http://img.youtube.com/vi/LApnUpnI094/0.jpg)](http://www.youtube.com/watch?v=LApnUpnI094)

**You need to add the ZMaterialButtonDelegate to your Controller:**
class ViewController: UIViewController, ZMaterialButtonDelegate {
}

**To create a Material UIButton init it with frame and set the Zdelegate, a .endPoint (CGPoint) and a .changeToImage (UIImage)**
Swift
```swift let containerView = UIView(frame: CGRect(x: 0, y: 200, width: self.view.frame.size.width, height: self.view.frame.size.height-200)) containerView.clipsToBounds = true self.view.addSubview(containerView)

self.button = ZMaterialButton(frame: CGRect(x: 10, y: 40, width: 100, height: 100)) self.button.setImage(UIImage(named: "play"), forState: UIControlState.Normal) self.button.backgroundColor = UIColor(red:0.05, green:0.69, blue:0.79, alpha:1) self.button.endPoint = CGPoint(x:self.view.center.x-50, y: self.view.center.y-50) self.button.changeToImage = UIImage(named: "pause") self.button.Zdelegate = self containerView.addSubview(self.button)

<h6>Obj-C</h6>
``` obj-c
ZMaterialButton *ZButton = [[ZMaterialButton alloc]initWithFrame:CGRectMake(40, 40, 50, 50)];
    [ZButton setImage:[UIImage imageNamed:@"play"] forState:UIControlStateNormal];
    [ZButton setBackgroundColor:[UIColor redColor]];
    [ZButton setEndAnimationPoint:CGPointMake(self.view.center.x-25, self.view.center.y-25)];
    ZButton.changeToImage = [UIImage imageNamed:@"pause"];
    ZButton.expandBy = 20;
    ZButton.originalParentViewColor = [UIColor whiteColor];
    ZButton.delegate = self;
    
    [self.view addSubview:ZButton];

**Add the delegate function ZMaterialButtonDidExpand() to your controller to know when the button expanded or reduced.**
Swift
```swift func ZMaterialButtonDidExpand(button: ZMaterialButton, expanded: Bool){ if expanded == true { self.testButtonExpanded() UIView.animateWithDuration(0.1, delay: 0, options: .CurveEaseOut, animations: { self.fButton.alpha = 1 self.bButton.alpha = 1 }, completion:nil) } else { self.testButtonReduced() UIView.animateWithDuration(0.2, delay: 0, options: .CurveEaseOut, animations: { self.fButton.alpha = 0 self.bButton.alpha = 0 }, completion:nil) } } ```
Obj-C
```obj-c - (void) ZMaterialButtonDidExpandButton:(ZMaterialButton *)button withSuccces:(BOOL)success{ if (success) { NSLog(@"Expanded"); } else { NSLog(@"Reduced"); } } ```

Hope you like it :]

Follow me on Twitter @richzertuche




鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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