{"id":7198,"date":"2025-05-30T13:20:15","date_gmt":"2025-06-05T05:59:14","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=7198"},"modified":"2025-06-05T13:20:15","modified_gmt":"2025-06-05T05:59:14","slug":"https-badgameshow-com-steven-272","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/swift\/https-badgameshow-com-steven-272\/","title":{"rendered":"Swift UISlider \u5b8c\u6574\u6307\u5357 \ud83c\udf9a\ufe0f\uff1a2025 \u6700\u65b0\u8a9e\u6cd5\u8207\u6700\u4f73\u5be6\u8e10"},"content":{"rendered":"<p>&#8220;`html<br \/>\n<meta name=\"keywords\" content=\"swift, UISlider, \u6ed1\u584a\u63a7\u5236\u5668, iOS, \u7a0b\u5f0f\u6559\u5b78, \u6700\u65b0\u8a9e\u6cd5\"><\/p>\n<h1>Swift UISlider \u5b8c\u6574\u6307\u5357 \ud83c\udf9a\ufe0f\uff1a2025 \u6700\u65b0\u8a9e\u6cd5\u8207\u6700\u4f73\u5be6\u8e10<\/h1>\n<p>Swift UISlider \ud83c\udf9a\ufe0f\u6ed1\u584a\u63a7\u5236\u5668\u662f iOS \u958b\u767c\u4e2d\u7684\u4e00\u500b\u91cd\u8981\u5de5\u5177\uff0c\u5b83\u80fd\u5920\u8b93\u4f7f\u7528\u8005\u8f15\u9b06\u5730\u8abf\u6574\u61c9\u7528\u7a0b\u5f0f\u7684\u8a2d\u5b9a\uff0c\u6bd4\u5982\u97f3\u91cf\u3001\u4eae\u5ea6\u7b49\uff0c\u7121\u9700\u91cd\u65b0\u555f\u52d5\u61c9\u7528\u7a0b\u5f0f\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 UISlider\uff0c\u5305\u62ec\u6700\u65b0\u7684\u8a9e\u6cd5\u548c\u6700\u4f73\u5be6\u8e10\u3002<\/p>\n<h2>UISlider \u57fa\u672c\u4f7f\u7528<\/h2>\n<p>\u8981\u5728\u4f60\u7684 iOS \u61c9\u7528\u7a0b\u5f0f\u4e2d\u4f7f\u7528 UISlider\uff0c\u4f60\u9700\u8981\u5148\u5275\u5efa\u4e00\u500b UISlider \u5be6\u4f8b\uff0c\u4ee5\u4e0b\u662f\u5efa\u7acb\u53ca\u914d\u7f6e UISlider \u7684\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff1a<\/p>\n<pre><code class=\"language-swift line-numbers\">let slider = UISlider(frame: CGRect(x: 20, y: 100, width: 280, height: 40))\nslider.minimumValue = 0\nslider.maximumValue = 100\nslider.value = 50\nslider.addTarget(self, action: #selector(sliderValueChanged(_:)), for: .valueChanged)\nview.addSubview(slider)<\/code><\/pre>\n<h2>\u8a2d\u7f6e\u6ed1\u584a\u984f\u8272<\/h2>\n<p>\u4f60\u53ef\u4ee5\u81ea\u5b9a\u7fa9\u6ed1\u584a\u7684\u5916\u89c0\uff0c\u4ee5\u4e0b\u662f\u5982\u4f55\u66f4\u6539\u6ed1\u584a\u984f\u8272\u7684\u7bc4\u4f8b\uff1a<\/p>\n<pre><code class=\"language-swift line-numbers\">slider.thumbTintColor = UIColor.red\nslider.minimumTrackTintColor = UIColor.blue\nslider.maximumTrackTintColor = UIColor.green<\/code><\/pre>\n<h2>\u97ff\u61c9\u6ed1\u584a\u8b8a\u66f4<\/h2>\n<p>\u7576\u6ed1\u584a\u7684\u503c\u6539\u8b8a\u6642\uff0c\u4f60\u9700\u8981\u76e3\u63a7\u9019\u500b\u8b8a\u5316\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u8a2d\u7f6e\u5c0d\u61c9\u7684\u51fd\u6578\uff1a<\/p>\n<pre><code class=\"language-swift line-numbers\">@objc func sliderValueChanged(_ sender: UISlider) {\n    print(\"Slider value is now: \\(sender.value)\")\n}<\/code><\/pre>\n<h2>\u5e38\u898b\u554f\u984c\u89e3\u7b54 (Q&#038;A)<\/h2>\n<h3>1. UISlider \u53ef\u4ee5\u7528\u65bc\u54ea\u4e9b\u5834\u666f\uff1f<\/h3>\n<p>UISlider \u901a\u5e38\u7528\u65bc\u97f3\u91cf\u63a7\u5236\u3001\u4eae\u5ea6\u8abf\u6574\u6216\u4efb\u4f55\u9700\u8981\u7528\u6236\u9078\u64c7\u7bc4\u570d\u6578\u503c\u7684\u529f\u80fd\u3002<\/p>\n<h3>2. \u5982\u4f55\u81ea\u5b9a\u7fa9 UISlider \u7684\u5916\u89c0\uff1f<\/h3>\n<p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>thumbTintColor<\/code>\u3001<code>minimumTrackTintColor<\/code> \u548c <code>maximumTrackTintColor<\/code> \u5c6c\u6027\u4f86\u6539\u8b8a UISlider \u7684\u984f\u8272\u548c\u6a23\u5f0f\u3002<\/p>\n<h3>3. UISlider \u7684\u503c\u5982\u4f55\u5132\u5b58\u548c\u4f7f\u7528\uff1f<\/h3>\n<p>\u7576\u6ed1\u584a\u7684\u503c\u6539\u8b8a\u6642\uff0c\u53ef\u4ee5\u900f\u904e <code>addTarget<\/code> \u65b9\u6cd5\u76e3\u63a7\uff0c\u4e26\u5728\u76f8\u61c9\u7684\u51fd\u6578\u4e2d\u4f7f\u7528\u6ed1\u584a\u7684\u503c\uff0c\u4f8b\u5982\u5132\u5b58\u5230\u8a2d\u5b9a\u6a94\u6216\u5373\u6642\u66f4\u65b0 UI\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2023\/02\/Swift-UISlider-\ud83c\udf9a\u6ed1\u584a\u63a7\u5236\u5668\uff01_1675404615.273389.webp\" alt=\"Swift UISlider \ud83c\udf9a\u6ed1\u584a\u63a7\u5236\u5668\uff01\" title=\"Swift UISlider, \u6ed1\u584a\u63a7\u5236\u5668, \u63a7\u5236App\u884c\u70ba, \u958b\u767c\u8005, App\u884c\u70ba\" width=\"1200\" height=\"628\"\/><\/p>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0cSwift UISlider \ud83c\udf9a\ufe0f\u6ed1\u584a\u63a7\u5236\u5668\u662f\u4e00\u500b\u975e\u5e38\u5be6\u7528\u7684\u5de5\u5177\uff0c\u80fd\u5920\u70ba\u7528\u6236\u63d0\u4f9b\u6d41\u66a2\u7684\u64cd\u4f5c\u9ad4\u9a57\u3002\u900f\u904e\u672c\u6587\u7684\u4ecb\u7d39\uff0c\u4f60\u61c9\u8a72\u80fd\u5920\u638c\u63e1 UISlider \u7684\u57fa\u672c\u7528\u6cd5\u8207\u9032\u968e\u8a2d\u7f6e\u3002<\/p>\n<p>&#8220;`<br \/>\n&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u672c\u6587\u5c07\u4ecb\u7d39Swift\u4e2dUISlider\u6ed1\u584a\u63a7\u5236\u5668\u7684\u529f\u80fd\uff0c\u4e26\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528\u5b83\u4f86\u63a7\u5236App\u7684\u884c\u70ba\uff0c\u8b93\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u8f15\u9b06\u5730\u63a7\u5236App\u7684\u884c\u70ba\u3002<\/p>\n","protected":false},"author":1,"featured_media":7197,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[174,5],"tags":[173,9],"class_list":["post-7198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios","category-swift","tag-ios","tag-swift"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2023\/02\/Swift-UISlider-\ud83c\udf9a\u6ed1\u584a\u63a7\u5236\u5668\uff01_1675404615.273389.webp","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1S6","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/7198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=7198"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/7198\/revisions"}],"predecessor-version":[{"id":13109,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/7198\/revisions\/13109"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media\/7197"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=7198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=7198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=7198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}