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

相关推荐
2501_915921436 小时前
iOS 是开源的吗?苹果系统的封闭与开放边界全解析(含开发与开心上架(Appuploader)实战)
android·ios·小程序·uni-app·开源·iphone·webview
2501_9159090610 小时前
原生 iOS 开发全流程实战,Swift 技术栈、工程结构、自动化上传与上架发布指南
android·ios·小程序·uni-app·自动化·iphone·swift
2501_9151063210 小时前
Comodo HTTPS 在工程中的部署与排查实战(证书链、兼容性与真机抓包策略)
网络协议·http·ios·小程序·https·uni-app·iphone
2501_9159090610 小时前
苹果软件混淆与 iOS 代码加固趋势,IPA 加密、应用防反编译与无源码保护的工程化演进
android·ios·小程序·https·uni-app·iphone·webview
2501_9160074710 小时前
苹果软件混淆与 iOS 应用加固实录,从被逆向到 IPA 文件防反编译与无源码混淆解决方案
android·ios·小程序·https·uni-app·iphone·webview
Zender Han15 小时前
Flutter 实现人脸检测 — 使用 google_mlkit_face_detection
android·flutter·ios
2501_9160088916 小时前
iOS 26 性能分析深度指南 包含帧率、渲染、资源瓶颈与 KeyMob 协助策略
android·macos·ios·小程序·uni-app·cocoa·iphone
Mr_zheng20 小时前
iOS 26 UIKit和Swift上的更新
ios·swift
YungFan20 小时前
iOS26适配指南之UISearchController
ios·swift
陈彬技术实践21 小时前
从 Auto Layout 原理看:为什么 UITableView.tableHeaderView 无法自动撑开?
ios