Shortly after Apple Swift was introduced, it was an accidental opportunity to come into contact with the language, and to look at its syntax casually:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvew5tyw95b25n/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
Instantly was moved, switch in unexpectedly boldly eliminated break, is completely anti-human practices. Other languages are less daring and smarter, basically switch, with a lot of break (no developer has ever considered tedious). Because the break was used at 99%, Apple simply omitted it. Of course you can use Fallthrough if you want to cross. Swift's strength also many omitted 1000 words here ...
Ability to download controls at the following address (no reservation, use whatever)
http://download.csdn.net/detail/ynmaoyong/8091225
To the next, here's a look at the control "Meterswift" instrumentation controls developed with Swift. This control executes on ios7+. There are several features:
1, the dial size is flexible, can be used under the conditions of 100x100 to 350x350.
2, scale flexibility to define the display maximum value, the degree of value.
3. Flexible change, replace the dial PNG, the hands PNG is your own control (no guilt, my graphics are down online).
4, easy to use, on a file, 2 graphics. Included in your project.
First, the use of controls
Effects used by the control:
Drag the slider to find that the needle is turning.
This control uses the following 2 libraries:
Open the interface below Xcode 6.1. You can join.
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvew5tyw95b25n/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
Talk about it below. How to use this control in your project. Code to speak:
@IBAction func Sliderchange (sender:uislider) {
Setting Display values
Panel.setcurrgaugevalue (CGFloat (sender.value), Animation:false)
Dislable.text = "Speed: \ (Int (sender.value)) km/h"
}
Override Func Viewdidload () {
Super.viewdidload ()
Initializing drawing range Parameters
Let frame = CGRectMake (10, 10, 151, 151)
Initializing the control
Panel = Gaugepanel (frame:frame)
Self.slider.maximumValue = MAXVALUE
Self.view.addSubview (panel)
Containview.addsubview (panel)
}
1. First put a view container on the interface.
2. Initialize the drawing scope of the control within the container.
3. Set the display value.
The following explains the configuration of the parameters in the Gauge.swift file
Maximum deflection angle
Letmaxoffsetangle:float = 120.0
Initialize pointer offset
Letpointeroffset:float = 90.0
Maximum display value
Letmaxvalue:float = 200.0
The number of degrees between large squares
Letcellmarknum:int = 5
Number of large squares
Letcellnum:int = 5
Text displayed in the center of the Dial
letgaugestring:string = "unit: km/h"
Default dial Size (square)
Letdefluatsize:int = 300
Load dial and pointer png
Self.pointer = Uiimageview (Image:uiimage (named: "Pointer2.png"))
Self.gaugeview = UIImage (named: "Gaugeback.png")
Developing dashboard controls with Swift (i)