当前位置: 首页>>代码示例>>Java>>正文


Java UIView.addSubview方法代码示例

本文整理汇总了Java中org.robovm.apple.uikit.UIView.addSubview方法的典型用法代码示例。如果您正苦于以下问题:Java UIView.addSubview方法的具体用法?Java UIView.addSubview怎么用?Java UIView.addSubview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robovm.apple.uikit.UIView的用法示例。


在下文中一共展示了UIView.addSubview方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addView

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public static void addView(UIView parent, UIView child, int index, LayoutParams lp) {
    if(!isViewGroup(parent)) {
        throw new UnsupportedOperationException("Views can only be added on ViewGroup objects");
    }

    if(!UIViewLayoutUtil.checkLayoutParams(parent, lp)) {
        if(lp != null) {
            lp = UIViewLayoutUtil.generateLayoutParams(parent, lp);
        }
        if(lp == null || !UIViewLayoutUtil.checkLayoutParams(parent, lp)) {
            lp = UIViewLayoutUtil.generateDefaultLayoutParams(parent);
        }
    }

    UIViewLayoutUtil.setLayoutParams(child, lp);

    if(index == -1) {
        parent.addSubview(child);
    } else {
        parent.insertSubview(child, index);
    }
    UIViewLayoutUtil.requestLayout(parent);
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:24,代码来源:UIViewViewGroupUtil.java

示例2: MyViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public MyViewController() {
    // Get the view of this view controller.
    UIView view = getView();

    // Setup background.
    view.setBackgroundColor(UIColor.white());

    // Setup label.
    label = new UILabel(new CGRect(20, 250, 280, 44));
    label.setFont(UIFont.getSystemFont(24));
    label.setTextAlignment(NSTextAlignment.Center);
    view.addSubview(label);

    // Setup button.
    button = new UIButton(UIButtonType.RoundedRect);
    button.setFrame(new CGRect(110, 150, 100, 40));
    button.setTitle("Click me!", UIControlState.Normal);
    button.getTitleLabel().setFont(UIFont.getBoldSystemFont(22));

    button.addOnTouchUpInsideListener((control, event) -> label.setText("Click Nr. " + (++clickCount)));
    view.addSubview(button);
}
 
开发者ID:robovm,项目名称:robovm-templates,代码行数:23,代码来源:MyViewController.java

示例3: PAPLoadMoreCell

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public PAPLoadMoreCell(UITableViewCellStyle style, String reuseIdentifier) {
    super(style, reuseIdentifier);

    setOpaque(false);
    setSelectionStyle(UITableViewCellSelectionStyle.None);
    setAccessoryType(UITableViewCellAccessoryType.None);
    setBackgroundColor(UIColor.clear());

    mainView = new UIView(getContentView().getFrame());
    if (reuseIdentifier.equals("NextPageDetails")) {
        mainView.setBackgroundColor(UIColor.white());
    } else {
        mainView.setBackgroundColor(UIColor.black());
    }

    loadMoreImageView = new UIImageView(UIImage.getImage("CellLoadMore"));
    mainView.addSubview(loadMoreImageView);

    getContentView().addSubview(mainView);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:21,代码来源:PAPLoadMoreCell.java

示例4: viewDidLoad

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
@Override
public void viewDidLoad() {
    super.viewDidLoad();

    getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("LogoNavigationBar")));

    getNavigationItem().setRightBarButtonItem(new PAPSettingsButtonItem(settingsButtonAction));

    blankTimelineView = new UIView(getTableView().getBounds());

    UIButton button = new UIButton(UIButtonType.Custom);
    button.setFrame(new CGRect(33, 96, 253, 173));
    button.setBackgroundImage(UIImage.getImage("HomeTimelineBlank"), UIControlState.Normal);
    button.addOnTouchUpInsideListener(inviteFriendsButtonAction);
    blankTimelineView.addSubview(button);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:17,代码来源:PAPHomeViewController.java

示例5: FeaturedViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public FeaturedViewController() {
    setTabBarItem(new UITabBarItem(UITabBarSystemItem.Featured, 0));

    UIView view = getView();
    view.setBackgroundColor(UIColor.fromRGBA(0.9, 1, 0.7, 1));

    titleLabel = new UILabel(new CGRect(0, 0, 100, 100));
    titleLabel.setFont(UIFont.getSystemFont(17));
    titleLabel.setText("Featured");
    titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
    view.addSubview(titleLabel);

    // Layout
    Map<String, NSObjectProtocol> views = new HashMap<>();
    views.put("parent", view);
    views.put("title", titleLabel);

    view.addConstraints(NSLayoutConstraint.createConstraints("H:[parent]-(<=1)-[title]",
            NSLayoutFormatOptions.AlignAllCenterY, null, views));
    view.addConstraints(NSLayoutConstraint.createConstraints("V:[parent]-(<=1)-[title]",
            NSLayoutFormatOptions.AlignAllCenterX, null, views));
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:FeaturedViewController.java

示例6: FavoritesViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public FavoritesViewController() {
    setTabBarItem(new UITabBarItem(UITabBarSystemItem.Favorites, 0));

    UIView view = getView();
    view.setBackgroundColor(UIColor.fromRGBA(0.77, 1, 1, 1));

    titleLabel = new UILabel(new CGRect(0, 0, 100, 100));
    titleLabel.setFont(UIFont.getSystemFont(17));
    titleLabel.setText("Favorites");
    titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
    view.addSubview(titleLabel);

    // Layout
    Map<String, NSObjectProtocol> views = new HashMap<>();
    views.put("parent", view);
    views.put("title", titleLabel);

    view.addConstraints(NSLayoutConstraint.createConstraints("H:[parent]-(<=1)-[title]",
            NSLayoutFormatOptions.AlignAllCenterY, null, views));
    view.addConstraints(NSLayoutConstraint.createConstraints("V:[parent]-(<=1)-[title]",
            NSLayoutFormatOptions.AlignAllCenterX, null, views));
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:FavoritesViewController.java

示例7: LandscapeViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public LandscapeViewController() {
    UIView view = getView();
    view.setBackgroundColor(UIColor.white());

    imageView = new UIImageView(new CGRect(0, 0, 568, 320));
    view.addSubview(imageView);

    UIButton button = new UIButton(new CGRect(20, 259, 49, 41));
    button.setImage(UIImage.getImage("left"), UIControlState.Normal);
    button.setImage(UIImage.getImage("left_pressed"),
            UIControlState.with(UIControlState.Selected, UIControlState.Highlighted));
    button.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
        @Override
        public void onTouchUpInside(UIControl control, UIEvent event) {
            dismissViewController(false, null);
        }
    });
    view.addSubview(button);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:LandscapeViewController.java

示例8: FourViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public FourViewController() {
    setTabBarItem(new UITabBarItem("Four", UIImage.getImage("tab4"), 0));

    UIView view = getView();
    view.setBackgroundColor(UIColor.fromRGBA(0.32, 1, 0.3, 1));

    titleLabel = new UILabel();
    titleLabel.setFont(UIFont.getSystemFont(17));
    titleLabel.setText("FOUR");
    titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
    view.addSubview(titleLabel);

    // Layout
    Map<String, NSObjectProtocol> views = new HashMap<>();
    views.put("parent", view);
    views.put("title", titleLabel);

    view.addConstraints(NSLayoutConstraint.createConstraints("H:[parent]-(<=1)-[title]",
            NSLayoutFormatOptions.AlignAllCenterY, null, views));
    view.addConstraints(NSLayoutConstraint.createConstraints("V:[parent]-(<=1)-[title]",
            NSLayoutFormatOptions.AlignAllCenterX, null, views));
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:23,代码来源:FourViewController.java

示例9: MyViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public MyViewController() {
    // Get the view of this view controller.
    UIView view = getView();

    // Get the bounds of the view.
    double viewWidth = view.getBounds().getWidth();
    double viewHeight = view.getBounds().getHeight();

    // Setup a label. Centered in the top half of the screen.
    double labelWidth = viewWidth;
    double labelHeight = 150;
    double labelX = (viewWidth - labelWidth) / 2.0;
    double labelY = (viewHeight * 1.0 / 4.0) - labelHeight / 2.0;
    label = new UILabel(new CGRect(labelX, labelY, labelWidth, labelHeight));
    label.setFont(UIFont.getSystemFont(40));
    label.setTextAlignment(NSTextAlignment.Center);
    view.addSubview(label);

    // Setup a button. Centered in the bottom half of the screen.
    double buttonWidth = viewWidth - 200;
    double buttonHeight = 150;
    double buttonX = (viewWidth - buttonWidth) / 2.0;
    double buttonY = (viewHeight * 3.0 / 4.0) - buttonHeight / 2.0;
    button = new UIButton(UIButtonType.RoundedRect);
    button.setFrame(new CGRect(buttonX, buttonY, buttonWidth, buttonHeight));
    button.setTitle("Click me!", UIControlState.Normal);
    button.getTitleLabel().setFont(UIFont.getBoldSystemFont(40));

    // Listen on clicks on the button and update the label.
    button.addOnPrimaryActionTriggeredListener((control) -> label.setText("Click Nr. " + (++clickCount)));
    view.addSubview(button);
}
 
开发者ID:robovm,项目名称:robovm-templates,代码行数:33,代码来源:MyViewController.java

示例10: PAPPhotoDetailsFooterView

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public PAPPhotoDetailsFooterView(CGRect frame) {
    super(frame);

    setBackgroundColor(UIColor.clear());

    mainView = new UIView(new CGRect(0, 0, UIScreen.getMainScreen().getBounds().getWidth(), 51));
    mainView.setBackgroundColor(UIColor.white());
    addSubview(mainView);

    UIImageView messageIcon = new UIImageView(UIImage.getImage("IconAddComment"));
    messageIcon.setFrame(new CGRect(20, 15, 22, 22));
    mainView.addSubview(messageIcon);

    UIImageView commentBox = new UIImageView(UIImage.getImage("TextFieldComment").newResizableImage(
            new UIEdgeInsets(10, 10, 10, 10)));
    commentBox.setFrame(new CGRect(55, 8, 237, 34));
    mainView.addSubview(commentBox);

    commentField = new UITextField(new CGRect(66, 8, 217, 34));
    commentField.setFont(UIFont.getSystemFont(14));
    commentField.setPlaceholder("Add a comment");
    commentField.setReturnKeyType(UIReturnKeyType.Send);
    commentField.setTextColor(UIColor.fromRGBA(34f / 255f, 34f / 255f, 34f / 255f, 1));
    commentField.setContentVerticalAlignment(UIControlContentVerticalAlignment.Center);
    commentField.getKeyValueCoder().setValue("_placeholderLabel.textColor",
            UIColor.fromRGBA(114f / 255f, 114f / 255f, 114f / 255f, 1));
    mainView.addSubview(commentBox);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:29,代码来源:PAPPhotoDetailsFooterView.java

示例11: viewDidLoad

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
@Override
public void viewDidLoad() {
    getTableView().setSeparatorStyle(UITableViewCellSeparatorStyle.SingleLine);

    super.viewDidLoad();

    UIView texturedBackgroundView = new UIView(getView().getBounds());
    texturedBackgroundView.setBackgroundColor(UIColor.black());
    getTableView().setBackgroundView(texturedBackgroundView);

    getNavigationItem().setTitleView(new UIImageView(UIImage.getImage("LogoNavigationBar")));

    // Add Settings button
    getNavigationItem().setRightBarButtonItem(new PAPSettingsButtonItem(settingsButtonAction));

    applicationDidReceiveRemoteNotification = PAPNotificationManager.addObserver(
            PAPNotification.DID_RECEIVE_REMOTE_NOTIFICATION, new VoidBlock1<NSNotification>() {
                @Override
                public void invoke(NSNotification notification) {
                    loadObjects();
                }
            });

    blankTimelineView = new UIView(getTableView().getBounds());

    UIButton button = new UIButton(UIButtonType.Custom);
    button.setBackgroundImage(UIImage.getImage("ActivityFeedBlank"), UIControlState.Normal);
    button.setFrame(new CGRect(24, 113, 271, 140));
    button.addOnTouchUpInsideListener(inviteFriendsButtonAction);
    blankTimelineView.addSubview(button);

    lastRefresh = PAPCache.getSharedCache().getLastActivityFeedRefresh();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:34,代码来源:PAPActivityFeedViewController.java

示例12: StreetScrollerViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public StreetScrollerViewController() {
    UIView view = getView();

    infiniteScrollView = new InfiniteScrollView(new CGRect(0, 0, 320, 460));
    infiniteScrollView.setBackgroundColor(UIColor.blue());
    view.addSubview(infiniteScrollView);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:8,代码来源:StreetScrollerViewController.java

示例13: MyLocalMovieViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public MyLocalMovieViewController() {
    super();

    UIView view = getView();
    view.setBackgroundColor(UIColor.fromWhiteAlpha(0.66, 1));

    imageView = new MyImageView(new CGRect(57, 59, 205, 135));
    imageView.setMovieViewController(this);
    imageView.setUserInteractionEnabled(true);
    imageView.setImage(UIImage.getImage("images/preview.jpg"));
    imageView.setContentMode(UIViewContentMode.ScaleAspectFit);
    view.addSubview(imageView);

    playButton = new UIButton(UIButtonType.RoundedRect);
    playButton.setFrame(new CGRect(106, 201, 108, 44));
    playButton.setBackgroundColor(UIColor.fromWhiteAlpha(0.66, 0.5));
    playButton.setTitle("Play Movie", UIControlState.Normal);
    playButton.getTitleLabel().setFont(UIFont.getSystemFont(18));
    playButton.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
        @Override
        public void onTouchUpInside(UIControl control, UIEvent event) {
            playLocalMovieFile();
        }
    });
    view.addSubview(playButton);

    setTabBarItem(new UITabBarItem("Local", UIImage.getImage("images/local.png"), 0));
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:29,代码来源:MyLocalMovieViewController.java

示例14: ModalViewController

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public ModalViewController() {
    UIView view = getView();
    view.setBackgroundColor(UIColor.white());

    titleLabel = new UILabel();
    titleLabel.setFont(UIFont.getSystemFont(17));
    titleLabel.setTranslatesAutoresizingMaskIntoConstraints(false);
    view.addSubview(titleLabel);

    UIButton button = new UIButton(UIButtonType.RoundedRect);
    button.setTitle("Done", UIControlState.Normal);
    button.setTitleShadowColor(UIColor.fromWhiteAlpha(0.5, 1), UIControlState.Normal);
    button.setTranslatesAutoresizingMaskIntoConstraints(false);
    button.addOnTouchUpInsideListener(new UIControl.OnTouchUpInsideListener() {
        @Override
        public void onTouchUpInside(UIControl control, UIEvent event) {
            dismissViewController(true, null);
        }
    });
    view.addSubview(button);

    // Layout
    Map<String, NSObjectProtocol> views = new HashMap<>();
    views.put("parent", view);
    views.put("title", titleLabel);
    views.put("done", button);

    view.addConstraints(NSLayoutConstraint.createConstraints("H:[parent]-(<=1)-[title]",
            NSLayoutFormatOptions.AlignAllCenterY, null, views));
    view.addConstraints(NSLayoutConstraint.createConstraints("V:[parent]-(<=1)-[title]-33-[done]",
            NSLayoutFormatOptions.AlignAllCenterX, null, views));
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:33,代码来源:ModalViewController.java

示例15: parseInclude

import org.robovm.apple.uikit.UIView; //导入方法依赖的package包/类
public void parseInclude(Element element, UIView parentView, Map<String, String> attrs) {
    if(!UIViewViewGroupUtil.isViewGroup(parentView)) {
        Foundation.log("<include /> can only be used in view groups");
        return;
    }

    String layoutToInclude = attrs.get(INCLUDE_ATTRIBUTE_LAYOUT);
    if(layoutToInclude == null) {
        Foundation.log("You must specify a layout in the include tag: <include layout=\\\"@layout/layoutName\\\" />");
    } else {
        NSURL url = ResourceManager.getCurrent().getLayoutURL(layoutToInclude);
        if(url == null) {
            Foundation.log(String.format("You must specify a valid layout reference. The layout ID %s is not valid.", layoutToInclude));
        } else {
            try {
                Document xml = ResourceManager.getCurrent().getXmlCache().getXML(url);
                Element rootElement = xml.getDocumentElement();
                String elementName = rootElement.getTagName();

                Map<String, String> childAttrs = getAttributes(rootElement, null);
                Element firstElementChild = DOMUtil.getFirstElementChild(rootElement);

                if(elementName.equals(TAG_MERGE) && firstElementChild != null) {
                    recursiveInflate(firstElementChild, parentView, childAttrs, true);
                } else {
                    UIView temp = createView(elementName, childAttrs, parentView);

                    // We try to load the layout params set in the <include /> tag. If
                    // they don't exist, we will rely on the layout params set in the
                    // included XML file.
                    // During a layoutparams generation, a runtime exception is thrown
                    // if either layout_width or layout_height is missing. We catch
                    // this exception and set localParams accordingly: true means we
                    // successfully loaded layout params from the <include /> tag,
                    // false means we need to rely on the included layout params.
                    LayoutParams layoutParams = UIViewLayoutUtil.generateLayoutParams(parentView, attrs);
                    boolean validLayoutParams = UIViewLayoutUtil.checkLayoutParams(parentView, layoutParams);

                    if(!validLayoutParams && parentView instanceof LayoutParamsDelegate) {
                        layoutParams = UIViewLayoutUtil.generateLayoutParams(parentView, childAttrs);
                    } else if(!validLayoutParams) {
                        layoutParams = UIViewLayoutUtil.generateDefaultLayoutParams(parentView);
                    }
                    UIViewLayoutUtil.setLayoutParams(temp, layoutParams);

                    // Inflate all children
                    if(firstElementChild != null) {
                        recursiveInflate(firstElementChild, temp, childAttrs, true);
                    }

                    // Attempt to override the included layout's id with the
                    // one set on the <include /> tag itself.
                    String overwriteIdentifier = attrs.get("id");
                    if(overwriteIdentifier != null) {
                        UIViewLayoutUtil.setIdentifier(temp, overwriteIdentifier);
                    }

                    // While we're at it, let's try to override visibility.
                    String overwriteVisibility = attrs.get("visibility");
                    if(overwriteVisibility != null) {
                        UIViewLayoutUtil.setVisibility(temp, ViewVisibility.get(overwriteVisibility));
                    }
                    parentView.addSubview(temp);
                }

            } catch (IOException e) {
                e.printStackTrace();
                Foundation.log(String.format("Cannot include layout %s: %s %s", layoutToInclude, e.getLocalizedMessage(), e.getCause()));
            }
        }
    }
}
 
开发者ID:liraz,项目名称:robolayout,代码行数:73,代码来源:LayoutInflater.java


注:本文中的org.robovm.apple.uikit.UIView.addSubview方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。