{"id":5635,"date":"2016-12-19T15:43:58","date_gmt":"2016-12-19T23:43:58","guid":{"rendered":"https:\/\/blog.mhvt.net\/?p=5635"},"modified":"2016-12-19T15:43:58","modified_gmt":"2016-12-19T23:43:58","slug":"ios-swift-making-custom-slider-with-uiview","status":"publish","type":"post","link":"https:\/\/blog.mhvt.net\/?p=5635","title":{"rendered":"iOS &#038; Swift &#8211; Making Custom Slider With UIView"},"content":{"rendered":"<p><a href=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"mac\/mac_shareware\/iphoneImage.jpg\" width=\"120\" height=\"120\" alt=\"iPhone custom slider\" \/><\/a><br \/>\n<br \/><\/br><br \/>\n<br \/><\/br><br \/>\nTOKYO (MacHouse) &#8211; It&#8217;s been 7 months since I started developing software in <strong>Swift<\/strong>.  I didn&#8217;t quite like Swift at the beginning because it&#8217;s totally different from <strong>Objective-C<\/strong> especially in the way it defines variables without data types.  Well, I have a changed heart.  I love Swift.<\/p>\n<p>Anyway, one thing that I don&#8217;t like about <strong>iOS<\/strong> is its ugly <strong>UISlider<\/strong>.  The touch part is a big circle, and it comes with a very thin, blue, horizontal line.  Yuck!  It&#8217;s ugly.  So I&#8217;ve decided to make my own custom slider. &nbsp; <!--more--><br \/>\n<br \/><\/br><\/p>\n<table width=\"464\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tr>\n<td width=\"220\" valign=\"top\"><a href=\"mac\/mac_shareware\/slidermonster\/SliderMonsterSimulator.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"mac\/mac_shareware\/slidermonster\/_thumbnail_SliderMonsterSimulator.jpg\" width=\"220\" height=\"406\" alt=\"iPhone custom slider\"\/><\/a><\/a><\/p>\n<div align=\"center\">Screenshot 1<\/div>\n<\/td>\n<td width=\"20\">&nbsp;<\/td>\n<td width=\"220\" valign=\"top\"><a href=\"mac\/mac_shareware\/slidermonster\/SliderMonsterXcode.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"mac\/mac_shareware\/slidermonster\/_thumbnail_SliderMonsterXcode.jpg\" width=\"220\" height=\"126\" alt=\"iPhone custom slider\"\/><\/a><\/a><\/p>\n<div align=\"center\">Screenshot 2<\/div>\n<\/td>\n<\/tr>\n<\/table>\n<p><\/br><br \/>\nTaking a quick look, a resulting slider looks seeminly better than UISlider.  (See Screenshot 1.)  But considering the amount of effort that I&#8217;ve made in making this slider, I wonder if it&#8217;s all that worth it.  Well, I&#8217;ve spent more than 6 hours since I started from scratch.  This slider is the result of three <strong>UIView<\/strong> suclasses (RoundView.swift, TouchView.swift, TicksView.swift).  (See Screenshot 2.)<br \/>\n<br \/><\/br><br \/>\nClick <a href=\"mac\/mac_shareware\/slidermonster\/SliderMonster.mov\">here<\/a> to watch a quick iPhone Simulator QuickTime movie.<br \/>\n<br \/><\/br><br \/>\nIn order to create a UIView-based custom slider like the one shown in Screenshot 1, you need to now how to allow the user to move a UIView object with the <strong>touchesMoved<\/strong> method.  You also have to know how to send the touch location value from UIView to UIViewController with <strong>protocol<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TOKYO (MacHouse) &#8211; It&#8217;s been 7 months since I started developing software in Swift. I didn&#8217;t quite like Swift at the beginning because it&#8217;s totally different from Objective-C especially in the way it defines variables without data types. Well, I &hellip; <a href=\"https:\/\/blog.mhvt.net\/?p=5635\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":342,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[504,507],"tags":[],"class_list":["post-5635","post","type-post","status-publish","format-standard","hentry","category-ios","category-swift"],"_links":{"self":[{"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=\/wp\/v2\/posts\/5635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=\/wp\/v2\/users\/342"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5635"}],"version-history":[{"count":14,"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=\/wp\/v2\/posts\/5635\/revisions"}],"predecessor-version":[{"id":5649,"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=\/wp\/v2\/posts\/5635\/revisions\/5649"}],"wp:attachment":[{"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mhvt.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}