title: How to change UIPickerView width with multiple Pickers in SwiftUI?
body: <p>I need to use an UIPickerView instead of the SwiftUI Picker since there are some bugs with it and I need more control over it.</p>
  <p>Everything works fine with the approach below, however, I need a picker which has a smaller width (something around 70% of the original width) but still shows all three pickers and still has the rounded corners of the gray background (so the gray background frame width and the spacing between the three pickers should decrease).</p>
  <p>I tried to modify the frame of the picker and its superview but that didn't work at all. Setting the frame width in SwiftUI and then using the clipped modifier cuts off the rounded edges and also cuts off some parts of the numbers (so that's out of the question).</p>
  <p>Does somebody know how to do this? Thanks a lot!</p>
  <p><a href="https://i.stack.imgur.com/vQha6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vQha6.png" alt="enter image description here" /></a></p>
  <pre><code>import SwiftUI
  
  struct ContentView: View {
  
      @State private var selections: [Int] = [5, 10, 50]
  
      var body: some View {
          MainPicker(pickerSelections: self.$selections)
      }
  }
  
  struct MainPicker: View {
      
      @Binding var pickerSelections: [Int]
      
      private let data: [[String]] = [
          Array(0...59).map { &quot;\($0 &lt; 10 ? &quot;0&quot; : &quot;&quot;)&quot; + &quot;\($0)&quot; },
          Array(0...59).map { &quot;\($0 &lt; 10 ? &quot;0&quot; : &quot;&quot;)&quot; + &quot;\($0)&quot; },
          Array(0...59).map { &quot;\($0 &lt; 10 ? &quot;0&quot; : &quot;&quot;)&quot; + &quot;\($0)&quot; }
      ]
      
      var body: some View {
          HStack{
              PickerView(data: data, selections: self.$pickerSelections)
          }
      }
  }
  
  struct PickerView: UIViewRepresentable {
      var data: [[String]]
      @Binding var selections: [Int]
  
      //makeCoordinator()
      func makeCoordinator() -&gt; PickerView.Coordinator {
          Coordinator(self)
      }
  
      //makeUIView(context:)
      func makeUIView(context: UIViewRepresentableContext&lt;PickerView&gt;) -&gt; UIPickerView {
  
          let hoursLabel = UILabel()
          let minLabel = UILabel()
          let secLabel = UILabel()
          hoursLabel.text = &quot;h&quot;
          minLabel.text = &quot;m&quot;
          secLabel.text = &quot;s&quot;
          
          let picker = UIPickerView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) //doesnt work
          
          
          picker.dataSource = context.coordinator
          picker.delegate = context.coordinator
          
          picker.superview?.frame = CGRect(x: 0, y: 0, width: 100, height: 100) //doesnt work
          
          return picker
      }
  
      //updateUIView(_:context:)
      func updateUIView(_ view: UIPickerView, context: UIViewRepresentableContext&lt;PickerView&gt;) {
          for i in 0...(self.selections.count - 1) {
              if(context.coordinator.initialSelection[i] != self.selections[i]){
                  view.selectRow(self.selections[i], inComponent: i, animated: false)
                  context.coordinator.initialSelection[i] = self.selections[i]
              }
          }
      }
  
      class Coordinator: NSObject, UIPickerViewDataSource, UIPickerViewDelegate {
          var parent: PickerView
          var initialSelection = [-1, -1, -1]
          
          //init(_:)
          init(_ pickerView: PickerView) {
              
              self.parent = pickerView
          }
  
          //numberOfComponents(in:)
          func numberOfComponents(in pickerView: UIPickerView) -&gt; Int {
              return self.parent.data.count
          }
  
          //pickerView(_:numberOfRowsInComponent:)
          func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
              return self.parent.data[component].count
          }
          
          func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -&gt; CGFloat {
              return 50
          }
  
          //pickerView(_:titleForRow:forComponent:)
          func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String? {
              return self.parent.data[component][row]
          }
  
          //pickerView(_:didSelectRow:inComponent:)
          func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
              self.parent.selections[component] = row
          }
      }
  }
  
  </code></pre>