image.png
Objective-C
@property (nonatomic, copy) NSString *str;
C#
public string Str { get; set; }
Objective-C
- (void)setStr:(NSString *)str
C#
string str;
public string Str {
get {
return str;
}
set {
str = value;
}
}
Objective-C
MyTextField *myTextField = [[MyTextField alloc] init];
MyTextField *myTextField2 = [[MyTextField alloc] init];
NSArray<MyTextField *> *array = @[myTextField, myTextField2];
C#
MyEntry entry1 = new MyEntry();
MyEntry entry2 = new MyEntry();
List<MyEntry> myList = new List<MyEntry> { entry1, entry2 };
//初始化
- (instancetype)init {
self = [super init];
if (self) {
self.backgroundColor = [UIColor redColor];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor redColor];
}
return self;
}
//带参数的初始化
- (instancetype)initWithStr:(NSString *)str {
self = [super init];
if (self) {
self.backgroundColor = [UIColor redColor];
self.text = str;
}
return self;
}
C#
public class MyEntry : Entry
{
//初始化
public MyEntry()
{
this.BackgroundColor = Color.Red;
}
//带参数的初始化
public MyEntry(string str){
this.BackgroundColor = Color.Red;
this.Text = str;
}
}
Objective-C
#import "UITextField+Extensions.h"
@implementation UITextField (Extensions)
- (void)textStr:(NSString *)str {
self.text = str;
}
@end
C#
public static class EntryExtensions
{
public static void TextStr(this Entry entrt, string str)
{
entrt.Text = str;
}
}
Objective-C
[UIView animateWithDuration:1.0 animations:^{
self.view.alpha = 0.0;
}];
C#
Animate(1.0, () => {
self.view.alpha = 0.0;
});