Exemple #1
0
    def create(self):
        # Hack! Because UISwitch has no label, we place it in a UITableViewCell to get a label
        self.native = UITableViewCell.alloc().initWithStyle_reuseIdentifier_(UITableViewCellStyleDefault, 'row')
        self.native.interface = self.interface

        self.native_switch = TogaSwitch.alloc().init()
        self.native_switch.interface = self.interface
        self.native_switch.addTarget_action_forControlEvents_(self.native_switch, SEL('onPress:'),
                                                              UIControlEventValueChanged)
        # Add Switch to UITableViewCell
        self.native.accessoryView = self.native_switch

        # Add the layout constraints
        self.add_constraints()

        fitting_size = self.native.systemLayoutSizeFittingSize_(CGSize(0, 0))
        self.interface.style.hint(
            min_height=fitting_size.height,
            min_width=fitting_size.width,
        )
Exemple #2
0
 def rehint(self):
     fitting_size = self.native.systemLayoutSizeFittingSize_(CGSize(0, 0))
     self.interface.style.hint(height=fitting_size.height,
                               width=fitting_size.width)
Exemple #3
0
 def rehint(self):
     # Height of a text input is known.
     fitting_size = self.native.systemLayoutSizeFittingSize_(CGSize(0, 0))
     self.interface.style.hint(height=fitting_size.height, min_width=100)
Exemple #4
0
 def rehint(self):
     # Width & height of a label is known and fixed.
     # print("REHINT label", self, self.native.fittingSize().width, self.native.fittingSize().height)
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = fitting_size.height
Exemple #5
0
 def rehint(self):
     fitting_size = self.native.systemLayoutSizeFittingSize(CGSize(0, 0))
     self.interface.intrinsic.width = at_least(fitting_size.width)
     self.interface.intrinsic.height = at_least(fitting_size.height)