Skip to content

Commit fed9766

Browse files
committed
improve knob
1 parent 6d8a4a3 commit fed9766

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

AKSynthOneKnob.pcvd

-770 Bytes
Binary file not shown.

KnobStyleKit.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ public class KnobStyleKit : NSObject {
1919

2020
//// Drawing Methods
2121

22-
@objc dynamic public class func drawKnobOne(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 120, height: 120), resizing: ResizingBehavior = .aspectFit, knobValue: CGFloat = 0.5) {
22+
@objc dynamic public class func drawKnobOne(frame targetFrame: CGRect = CGRect(x: 0, y: 0, width: 124, height: 124), resizing: ResizingBehavior = .aspectFit, knobValue: CGFloat = 0.5) {
2323
//// General Declarations
2424
let context = UIGraphicsGetCurrentContext()!
2525

2626
//// Resize to Target Frame
2727
context.saveGState()
28-
let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 120, height: 120), target: targetFrame)
28+
let resizedFrame: CGRect = resizing.apply(rect: CGRect(x: 0, y: 0, width: 124, height: 124), target: targetFrame)
2929
context.translateBy(x: resizedFrame.minX, y: resizedFrame.minY)
30-
context.scaleBy(x: resizedFrame.width / 120, y: resizedFrame.height / 120)
31-
let resizedShadowScale: CGFloat = min(resizedFrame.width / 120, resizedFrame.height / 120)
30+
context.scaleBy(x: resizedFrame.width / 124, y: resizedFrame.height / 124)
31+
let resizedShadowScale: CGFloat = min(resizedFrame.width / 124, resizedFrame.height / 124)
3232

3333

3434
//// Color Declarations
@@ -62,6 +62,7 @@ public class KnobStyleKit : NSObject {
6262

6363
//// Knob
6464
context.saveGState()
65+
context.translateBy(x: 3, y: 3)
6566

6667

6768

KnobView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class KnobView: UIView {
6161
override func prepareForInterfaceBuilder() {
6262
super.prepareForInterfaceBuilder()
6363

64-
contentMode = .center
64+
contentMode = .scaleAspectFit
6565
clipsToBounds = true
6666
}
6767

SynthUISpike/Base.lproj/Main.storyboard

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2323
<subviews>
2424
<view contentMode="center" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="DJU-Fx-KsR" customClass="KnobView" customModule="SynthUISpike" customModuleProvider="target">
25-
<rect key="frame" x="184" y="64" width="143" height="126"/>
25+
<rect key="frame" x="175" y="103" width="130" height="130"/>
2626
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2727
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
2828
</view>

0 commit comments

Comments
 (0)