@IBAction public void toggleRecording() { if (!movieFileOutput.isRecording()) { recordButton.setImage(UIImage.create("player_stop"), UIControlState.Normal); startRecording(); } else { recordButton.setImage(UIImage.create("player_record"), UIControlState.Normal); movieFileOutput.stopRecording(); if (timer.isValid()) { timer.invalidate(); } } }
public PrefillRoboVMAccountInstructionsView() { setBackgroundColor(Colors.White); UIImageView mockup = new UIImageView(UIImage.getImage("fill-details-instructions-mockup")); mockup.setTranslatesAutoresizingMaskIntoConstraints(false); addSubview(mockup); addConstraint( new NSLayoutConstraint( mockup, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterX, 1, 0)); addConstraint( new NSLayoutConstraint( mockup, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1, -40)); }
@Override public void viewDidLoad() { super.viewDidLoad(); getTableView().setSeparatorStyle(UITableViewCellSeparatorStyle.None); getTableView().setBackgroundColor(UIColor.black()); getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("TitleFindFriends"))); if (getNavigationController().getViewControllers().first() == this) { UIBarButtonItem dismissLeftBarButtonItem = new UIBarButtonItem( "Back", UIBarButtonItemStyle.Plain, new UIBarButtonItem.OnClickListener() { @Override public void onClick(UIBarButtonItem barButtonItem) { getNavigationController().dismissViewController(true, null); } }); getNavigationItem().setLeftBarButtonItem(dismissLeftBarButtonItem); } else { getNavigationItem().setLeftBarButtonItem(null); } if (MFMailComposeViewController.canSendMail() || MFMessageComposeViewController.canSendText()) { headerView = new UIView(new CGRect(0, 0, 320, 67)); headerView.setBackgroundColor(UIColor.black()); UIButton clearButton = new UIButton(UIButtonType.Custom); clearButton.setBackgroundColor(UIColor.clear()); clearButton.addOnTouchUpInsideListener(inviteFriendsButtonAction); clearButton.setFrame(headerView.getFrame()); headerView.addSubview(clearButton); String inviteString = "Invite friends"; CGRect boundingRect = NSString.getBoundingRect( inviteString, new CGSize(310, Float.MAX_VALUE), NSStringDrawingOptions.with( NSStringDrawingOptions.TruncatesLastVisibleLine, NSStringDrawingOptions.UsesLineFragmentOrigin), new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(18)), null); CGSize inviteStringSize = boundingRect.getSize(); UILabel inviteLabel = new UILabel( new CGRect( 10, (headerView.getFrame().getSize().getHeight() - inviteStringSize.getHeight()) / 2, inviteStringSize.getWidth(), inviteStringSize.getHeight())); inviteLabel.setText(inviteString); inviteLabel.setFont(UIFont.getBoldSystemFont(18)); inviteLabel.setTextColor(UIColor.white()); inviteLabel.setBackgroundColor(UIColor.clear()); headerView.addSubview(inviteLabel); getTableView().setTableHeaderView(headerView); } }
private void configureCustomSegmentsSegmentedControl() { Map<String, String> imageToAccessibilityLabelMappings = new HashMap<>(); imageToAccessibilityLabelMappings.put("checkmark_icon", "Done"); imageToAccessibilityLabelMappings.put("search_icon", "Search"); imageToAccessibilityLabelMappings.put("tools_icon", "Settings"); int i = 0; for (Map.Entry<String, String> entry : imageToAccessibilityLabelMappings.entrySet()) { UIImage image = UIImage.getImage(entry.getKey()); image.setAccessibilityLabel(entry.getValue()); customSegmentsSegmentedControl.setImage(image, i); i++; } customSegmentsSegmentedControl.setSelectedSegment(0); customSegmentsSegmentedControl.addOnValueChangedListener(this); }
private void configureCustomBackgroundSegmentedControl() { customBackgroundSegmentedControl.setSelectedSegment(2); // Set the background images for each control state. UIImage normalSegmentBackgroundImage = UIImage.getImage("stepper_and_segment_background"); customBackgroundSegmentedControl.setBackgroundImage( normalSegmentBackgroundImage, UIControlState.Normal, UIBarMetrics.Default); UIImage disabledSegmentBackgroundImage = UIImage.getImage("stepper_and_segment_background_disabled"); customBackgroundSegmentedControl.setBackgroundImage( disabledSegmentBackgroundImage, UIControlState.Disabled, UIBarMetrics.Default); UIImage highlightedSegmentBackgroundImage = UIImage.getImage("stepper_and_segment_background_highlighted"); customBackgroundSegmentedControl.setBackgroundImage( highlightedSegmentBackgroundImage, UIControlState.Highlighted, UIBarMetrics.Default); // Set the divider image. UIImage segmentDividerImage = UIImage.getImage("stepper_and_segment_segment_divider"); customBackgroundSegmentedControl.setDividerImage( segmentDividerImage, UIControlState.Normal, UIControlState.Normal, UIBarMetrics.Default); // Create a font to use for the attributed title (both normal and // highlighted states). UIFontDescriptor captionFontDescriptor = UIFontDescriptor.getPreferredFontDescriptor(UIFontTextStyle.Caption1); UIFont font = UIFont.getFont(captionFontDescriptor, 0); NSAttributedStringAttributes normalTextAttributes = new NSAttributedStringAttributes().setForegroundColor(Colors.PURPLE).setFont(font); customBackgroundSegmentedControl.setTitleTextAttributes( normalTextAttributes, UIControlState.Normal); NSAttributedStringAttributes highlightedTextAttributes = new NSAttributedStringAttributes().setForegroundColor(Colors.GREEN).setFont(font); customBackgroundSegmentedControl.setTitleTextAttributes( highlightedTextAttributes, UIControlState.Highlighted); customBackgroundSegmentedControl.addOnValueChangedListener(this); }
private void configureImageButton() { // To create this button in code you can use UIButton.create() with a // parameter value of UIButtonType.Custom. // Remove the title text. imageButton.setTitle("", UIControlState.Normal); imageButton.setTintColor(Colors.PURPLE); UIImage imageButtonNormalImage = UIImage.getImage("x_icon"); imageButton.setImage(imageButtonNormalImage, UIControlState.Normal); // Add an accessibility label to the image. imageButton.setAccessibilityLabel("X Button"); imageButton.addOnTouchUpInsideListener(this); }
public ProductDetailViewController(Product product) { this.currentProduct = product; this.order = new Order(product); setTitle(currentProduct.getName()); loadProductData(); getTableView().setTableFooterView(new UIView(new CGRect(0, 0, 0, BottomButtonView.HEIGHT))); tshirtIcon = UIImage.getImage("t-shirt"); bottomView = new BottomButtonView(); bottomView.setButtonText("Add to Basket"); bottomView.setButtonTapListener((b, e) -> addToBasket()); getView().addSubview(bottomView); }
private void addToBasket() { UINavigationController navigation = getNavigationController(); CGPoint center = bottomView .getButton() .convertPointToView( bottomView.getButton().getImageView().getCenter(), navigation.getView()); UIImageView imageView = new UIImageView(tshirtIcon); imageView.setCenter(center); imageView.setContentMode(UIViewContentMode.ScaleAspectFill); UIImageView backgroundView = new UIImageView(UIImage.getImage("circle")); backgroundView.setCenter(center); navigation.getView().addSubviews(backgroundView, imageView); UIView targetView = (UIView) getNavigationItem().getRightBarButtonItem().getKeyValueCoder().getValue("view"); CGPoint targetPosition = new CGPoint( targetView.getCenter().getX() + targetView.getFrame().getWidth() / 3, targetView.getCenter().getY() + targetView.getFrame().getHeight() / 2); animateView(imageView, targetPosition, null); animateView( backgroundView, targetPosition, () -> { getNavigationItem().setRightBarButtonItem(StoreApp.getInstance().createBasketButton()); }); if (addedToBasket != null) { addedToBasket.invoke(new Order(order)); } }
@Override public UIImage getTabBarImage() { return UIImage.getImage("name_gray.png"); }