博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS UISlider 通过点击改变value
阅读量:7104 次
发布时间:2019-06-28

本文共 453 字,大约阅读时间需要 1 分钟。

hot3.png

自定义一个继承于UISlider的类  重写touchesBegan方法:

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    CGRect t = [self trackRectForBounds: [self bounds]];

    float v = [self minimumValue] + ([[touches anyObject] locationInView: self].x - t.origin.x - 4.0) * (([self maximumValue]-[self minimumValue]) / (t.size.width - 8.0));

    [self setValue: v];

    [super touchesBegan: touches withEvent: event];

}

转载于:https://my.oschina.net/u/2488236/blog/613114

你可能感兴趣的文章
Ubuntu安装 和 python开发
查看>>
「洛谷P3931」 SAC E#1 - 一道难题 Tree
查看>>
C#压缩库SharpZipLib的应用
查看>>
C# Type
查看>>
我的博客地址和github地址
查看>>
最大公约数(gcd)还有最小公倍数(lcm)的共通之处
查看>>
2018.10.30-dtoj-4009-秀秀的森林(forest)
查看>>
[LeetCode] Strobogrammatic Number II
查看>>
《C语言》-(static和extern)
查看>>
HBase Snapshot简介
查看>>
一、Github博客搭建之jekyll安装
查看>>
利用js为table添加行
查看>>
配置Docker中国区官方镜像http://get.daocloud.io/ 很好的一个源http://get.daocloud.io/#install-docker...
查看>>
·ios 圆角
查看>>
[C#] 區分 abstract、virtual、override 和 new
查看>>
前端页面优化方案
查看>>
Micropython教程之TPYBoard开发板驱动舵机教程(萝卜学科编程教育)
查看>>
SQL开发技巧(二)
查看>>
性能测试方案和性能测试报告小结
查看>>
Qt中float类型与QString类型相互转换
查看>>