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

相关推荐
初级代码游戏5 天前
easy Photo Clean公测版:快速清理iPhone照片 邀请公测
ios·iphone
库奇噜啦呼5 天前
【iOS】RunLoop学习
学习·ios
黑科技iOS上架5 天前
iOS应用周末提交什么情况算卡审
经验分享·ios
zzb15805 天前
ios基础-MVC-UIView
ios·mvc·cocoa
kingbal5 天前
Flutter:Flutter SDK版本管理工具FVM
android·flutter·ios·android-studio·window
他们都不看好你,偏偏你最不争气5 天前
【iOS】Runtime - Part 2 && 消息发送:缓存、查找与转发
macos·ios·objective-c·cocoa
2501_915918416 天前
iOS App性能测试工具的实现方法与优化循环指南
android·ios·小程序·https·uni-app·iphone·webview
他们都不看好你,偏偏你最不争气6 天前
【iOS】Runtime - Part 1 && 对象与类的本质
macos·ios·objective-c·cocoa