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

相关推荐
小雨下雨的雨12 小时前
iOS风格计算器 - 鸿蒙PC Electron框架上的技术实现详解
游戏·ios·华为·electron·harmonyos·鸿蒙
人月神话Lee14 小时前
【图像处理】一文带你窥探近期火热图像App的主要实现原理:主色提取——从图像到调色板
ios·ai编程·图像识别
2601_955767421 天前
iPhone 17 全系屏幕光学特性与保护膜选型技术分析
ios·ar·iphone·圆偏振光护眼·iphone17护眼钢化膜·#观复盾护景贴
2501_915909061 天前
深入解析Mock.js:功能、应用及实战案例,提升前端开发效率
android·ios·小程序·https·uni-app·iphone·webview
pop_xiaoli1 天前
【iOS】通知传值实现
macos·ios·xcode
2601_955767421 天前
iPhone 17 屏幕偏振光学解析与保护贴技术选择——悟赫德观复盾护景贴
人工智能·科技·ios·ar·iphone·圆偏振光
qq3621967052 天前
手机App下载安装完全指南:2026最新教程(Android & iOS)
android·ios·智能手机
核电机组2 天前
IOS原生APP集成Flutter
flutter·ios