Skip to content

Commit

Permalink
Objective-C Bridging
Browse files Browse the repository at this point in the history
  • Loading branch information
maxep committed Aug 6, 2019
1 parent 7cb3478 commit d05b6c6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Example/CustomViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ class CustomViewController: UIViewController {
segmentedControl2.append(title: "Second")

segmentedControl3.append(title: "First")
.set(title: #colorLiteral(red: 0.9981629252, green: 0.6096215844, blue: 0.6670924425, alpha: 1), for: .selected)
.set(titleColor: #colorLiteral(red: 0.9981629252, green: 0.6096215844, blue: 0.6670924425, alpha: 1), for: .selected)
segmentedControl3.append(title: "Second")
.set(title: #colorLiteral(red: 1, green: 0.7996580601, blue: 0.4006214142, alpha: 1), for: .selected)
.set(titleColor: #colorLiteral(red: 1, green: 0.7996580601, blue: 0.4006214142, alpha: 1), for: .selected)
segmentedControl3.append(title: "Third")
.set(title: #colorLiteral(red: 0.9995033145, green: 0.9875727296, blue: 0.4039593935, alpha: 1), for: .selected)
.set(titleColor: #colorLiteral(red: 0.9995033145, green: 0.9875727296, blue: 0.4039593935, alpha: 1), for: .selected)
segmentedControl3.append(title: "Fourth")
.set(title: #colorLiteral(red: 0.8013994098, green: 0.9842005372, blue: 0.4007700682, alpha: 1), for: .selected)
.set(titleColor: #colorLiteral(red: 0.8013994098, green: 0.9842005372, blue: 0.4007700682, alpha: 1), for: .selected)
segmentedControl3.append(title: "Fifth")
.set(title: #colorLiteral(red: 0.4016934037, green: 0.9801344275, blue: 0.3977853954, alpha: 1), for: .selected)
.set(titleColor: #colorLiteral(red: 0.4016934037, green: 0.9801344275, blue: 0.3977853954, alpha: 1), for: .selected)

segmentedControl3.indicator.boxView.alpha = 0.1

Expand Down
6 changes: 3 additions & 3 deletions Example/TopBarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class TopBarViewController: UIViewController {
super.viewDidLoad()

segmentedControl.append(title: "Segmentio")
.set(title: #colorLiteral(red: 0.08598647267, green: 0.093843095, blue: 0.1104642078, alpha: 1), for: .selected)
.set(titleColor: #colorLiteral(red: 0.08598647267, green: 0.093843095, blue: 0.1104642078, alpha: 1), for: .selected)
segmentedControl.append(title: "HMSegmentedControl")
.set(title: #colorLiteral(red: 0.08598647267, green: 0.093843095, blue: 0.1104642078, alpha: 1), for: .selected)
.set(titleColor: #colorLiteral(red: 0.08598647267, green: 0.093843095, blue: 0.1104642078, alpha: 1), for: .selected)
segmentedControl.append(title: "Other")
.set(title: #colorLiteral(red: 0.9098039269, green: 0.4784313738, blue: 0.6431372762, alpha: 1), for: .selected)
.set(titleColor: #colorLiteral(red: 0.9098039269, green: 0.4784313738, blue: 0.6431372762, alpha: 1), for: .selected)

segmentedControl.indicator.lineView.backgroundColor = #colorLiteral(red: 0.9568627451, green: 0.4392156863, blue: 0.3803921569, alpha: 1)
segmentedControl.addTarget(self, action: #selector(changeIndex(segmentedControl:)), for: .valueChanged)
Expand Down
1 change: 1 addition & 0 deletions MXSegmentedControl/MXIndicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import UIKit

@objcMembers
public class MXIndicator: UIView {

/// The indicator line position
Expand Down
5 changes: 3 additions & 2 deletions MXSegmentedControl/MXSegment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import UIKit

/// A segment button embed in MXSegmentedControl
@objcMembers
public class MXSegment: UIButton {

/// The Image position in segment related to title.
Expand Down Expand Up @@ -75,8 +76,8 @@ public class MXSegment: UIButton {
return self
}

@discardableResult public func set(title color: UIColor?, for state: UIControl.State = .normal) -> MXSegment {
super.setTitleColor(color, for: state)
@discardableResult public func set(titleColor: UIColor?, for state: UIControl.State = .normal) -> MXSegment {
super.setTitleColor(titleColor, for: state)
return self
}

Expand Down
5 changes: 3 additions & 2 deletions MXSegmentedControl/MXSegmentedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import UIKit
/// You register the target-action methods for a segmented control using the value​Changed constant as shown below.
///
/// segmentedControl.addTarget(self, action: "action:", forControlEvents: .ValueChanged)
@IBDesignable open class MXSegmentedControl: UIControl {
@IBDesignable
@objcMembers
open class MXSegmentedControl: UIControl {

// MARK: Customizing Appearance

Expand Down Expand Up @@ -289,7 +291,6 @@ import UIKit
}

// MARK: - Interface Builder Inspectable and Appearence

extension MXSegmentedControl {

@IBInspectable public dynamic var cornerRadius: CGFloat {
Expand Down

0 comments on commit d05b6c6

Please sign in to comment.