iOS 改变uislider的滑块大小

简介

使用继承uislider并重写一些方法并不能实现改变滑块大小的要求,这里需要一张与要求的大小相同的图片设置到滑块上就可以了

代码
  • 下面是裁剪的代码

    • (UIImage*)image:(UIImage*)image scaleToSize:(CGSize)size{
      UIGraphicsBeginImageContext(size);//size为CGSize类型,即你所需要的图片尺寸
      [image drawInRect:CGRectMake(0,0, size.width, size.height)];
      UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();

      return scaledImage;
      }

  • 下面是设置滑块图片的代码

    UIImage *tempImage = [UIImage imageNamed:@"optometry_icon_point"];
    UIImage *tempImage1 = [UIImage image:tempImage scaleToSize:CGSizeMake(50, 50)];
    [tempView setThumbImage:tempImage1 forState:UIControlStateNormal];
    [tempView setThumbImage:tempImage1 forState:UIControlStateHighlighted];

相关推荐
TheNextByte11 小时前
如何在没有iTunes的情况下重启/恢复出厂设置iPhone
ios·cocoa·iphone
芝加哥兔兔养殖场3 小时前
前端/iOS开发者必备工具软件合集
前端·ios
TheNextByte14 小时前
如何从 iPhone 仅传输喜爱的照片?
ios·iphone
m0_641031054 小时前
iOS签名是什么?为什么苹果APP需要签名
经验分享·科技·ios·游戏程序
_pengliang5 小时前
react native expo 开发 ios经验总结
react native·react.js·ios
YJlio13 小时前
1.7 通过 Sysinternals Live 在线运行工具:不下载也能用的“云端工具箱”
c语言·网络·python·数码相机·ios·django·iphone
2501_941982051 天前
Go 开发实战:基于 RPA 接口的主动消息推送
ios·iphone
忆江南1 天前
Swift 全面深入指南
ios
00后程序员张1 天前
iOS 应用代码混淆,对已编译 IPA 进行类与方法混淆
android·ios·小程序·https·uni-app·iphone·webview
YJlio1 天前
1.6 使用 Streams 工具移除下载文件的 ADS 信息:把“来自互联网”的小尾巴剪掉
c语言·网络·python·数码相机·ios·django·iphone