Giter Site home page Giter Site logo

ffruler's Introduction

FFRuler

轻量级刻度尺控件

功能

  • 简单/灵活/小巧的刻度尺控件

屏幕截图

系统支持

  • iOS 7.0+
  • Xcode 7.0

安装

CocoaPods

  • 进入终端,cd 到项目目录,输入以下命令,建立 Podfile
$ pod init
  • 在 Podfile 中输入以下内容:
platform :ios, '7.0'
use_frameworks!

target 'FFRulerDemo' do
pod 'FFRuler'
end
  • 在终端中输入以下命令,安装或升级 Pod
# 安装 Pod,第一次使用
$ pod install

# 升级 Pod,后续使用
$ pod update

使用

  • 代码示例
#import "FFRulerControl.h"

@interface CodeDemoViewController ()
@property (weak, nonatomic) IBOutlet UILabel *weightLabel;
@end

@implementation CodeDemoViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    FFRulerControl *ruler = [[FFRulerControl alloc] initWithFrame:CGRectMake(0, 0, 300, 120)];
    ruler.center = self.view.center;

    [self.view addSubview:ruler];

    ruler.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1];

    // 最小值
    ruler.minValue = 10;
    // 最大值
    ruler.maxValue = 100;
    // 数值步长
    ruler.valueStep = 5;
    // 设置默认值
    ruler.selectedValue = 80;

    // 添加监听方法
    [ruler addTarget:self action:@selector(weightChanged:) forControlEvents:UIControlEventValueChanged];
}

- (void)weightChanged:(FFRulerControl *)ruler {
    _weightLabel.text = [NSString stringWithFormat:@"体重: %.02f kg", ruler.selectedValue];
}

@end
  • 也可以直接使用 Interface Builder 设置所有属性,并且连接 IBAction
- (IBAction)weightChanged:(FFRulerControl *)sender {
    _weightLabel.text = [NSString stringWithFormat:@"体重: %.02f kg", sender.selectedValue];
}

ffruler's People

Contributors

liufan321 avatar

Watchers

James Cloos 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.