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];

相关推荐
TheNextByte13 小时前
如何将文件从Android无线传输到 iPad
android·ios·ipad
2501_915106326 小时前
如何在iPad上高效管理本地文件的完整指南
android·ios·小程序·uni-app·iphone·webview·ipad
2501_915106326 小时前
iOS 成品包加固,在只有 IPA 的情况下,能做那些操作
android·ios·小程序·https·uni-app·iphone·webview
Free Tester7 小时前
在iPhone上显示点击屏幕点击的方法
功能测试·ios·iphone
AALoveTouch8 小时前
某麦APP抢票技术解析实现
android·ios
2501_9159090612 小时前
苹果iOS应用上架详细流程与注意事项解析
android·ios·小程序·https·uni-app·iphone·webview
莫桐13 小时前
微信小程序-ios环境下webview打开的h5页面replace跳转方式不生效问题
ios·微信小程序·小程序
搜狐技术产品小编202313 小时前
iOS OOM治理
macos·ios·objective-c·cocoa
2501_9159090614 小时前
在无需越狱的前提下如何对 iOS 设备进行文件管理与数据导出
android·macos·ios·小程序·uni-app·cocoa·iphone
@大迁世界15 小时前
Swift、Flutter 还是 React Native:2026 年你该学哪个
开发语言·flutter·react native·ios·swift