【发布时间】:2018-07-25 13:22:53
【问题描述】:
【问题讨论】:
-
您可以将 ios 代码转换为 c# 并执行以下链接 github.com/rsattar/CLTokenInputView
标签: ios xamarin xamarin.ios
【问题讨论】:
标签: ios xamarin xamarin.ios
您必须自己编写这个自定义组件。 我建议在 XIB/Storyboard 中设计这个并将它们放在运行时。
以编程方式创建这样一个子视图的非常粗略的想法可能类似于
var myView = new UIView(frame: new CoreGraphics.CGRect(10, 10, 120, 40));
myView.BackgroundColor = UIColor.Blue;
myView.Layer.CornerRadius = 20;
var mylabel = new UILabel(frame: new CoreGraphics.CGRect(10, 10, 80, 40));
mylabel.Text = "MUMBAI";
myView.Add(mylabel);
UIButton button = new UIButton();
button.Frame = new CoreGraphics.CGRect(mylabel.Frame.X + mylabel.Frame.Width, 10f, 40, 25);
button.SetTitle("Title", UIControlState.Normal);
button.SetBackgroundImage(UIImage.FromBundle("MyImage"),UIControlState.Normal);
myView.Add(button);
View.Add(myView);
这里你需要做框架计算,上面只是我放的一些示例框架。
所以最终你会让这些视图水平堆叠,当用户点击“x”按钮时,你会用动画改变框架。
【讨论】:
试试这个
https://github.com/nmilcoff/TagsView
上手超级简单:
public class ViewController : UIViewController
{
private TagListView tagsView;
public override void ViewDidLoad()
{
// code
this.tagsView = new TagListView()
{
// you can customize properties here!
};
this.View.AddSubview(this.tagsView);
this.View.AddConstraints(
// Add your constraints!
);
// you can attach a source object to each tag
var myObject = new MyModel { Title = "I'm a MyModel!" };
this.tagsView.AddTag(myObject.Title, myObject);
// but, if none is provided, it will be the text string
this.tagsView.AddTag("I'm a simple tag!");
}
}
【讨论】: