-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTableViewCell.cs
68 lines (56 loc) · 2.39 KB
/
TableViewCell.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Foundation;
using System;
using UIKit;
public class TableViewCell : UITableViewCell
{
public UILabel Title { get; set; }
public UILabel Subtitle { get; set; }
public UIImageView Icon { get; set; }
private nfloat padding = 12.0f;
public TableViewCell(IntPtr ptr) : base(ptr)
{
Init();
}
public TableViewCell(UITableViewCellStyle style, string reuseIdentifier) : base(style, reuseIdentifier)
{
Init();
}
private void Init()
{
Title = new UILabel
{
Font = UIFont.BoldSystemFontOfSize(17),
Lines = 0,
LineBreakMode = UILineBreakMode.WordWrap,
TranslatesAutoresizingMaskIntoConstraints = false
};
Subtitle = new UILabel
{
Font = UIFont.SystemFontOfSize(16),
TextColor = UIDevice.CurrentDevice.CheckSystemVersion(13, 0) ? UIColor.SecondaryLabel : UIColor.Black,
Lines = 0,
LineBreakMode = UILineBreakMode.WordWrap,
TranslatesAutoresizingMaskIntoConstraints = false
};
Icon = new UIImageView
{
ContentMode = UIViewContentMode.ScaleAspectFit,
TintColor = UIColor.SystemGray,
TranslatesAutoresizingMaskIntoConstraints = false
};
ContentView.AddSubview(Icon);
ContentView.AddSubview(Title);
ContentView.AddSubview(Subtitle);
Icon.TopAnchor.ConstraintEqualTo(ContentView.TopAnchor, padding).Active = true;
Icon.LeadingAnchor.ConstraintEqualTo(ContentView.LeadingAnchor, padding).Active = true;
Icon.BottomAnchor.ConstraintEqualTo(ContentView.BottomAnchor, -padding).Active = true;
Icon.WidthAnchor.ConstraintEqualTo(42).Active = true;
Title.TopAnchor.ConstraintEqualTo(ContentView.TopAnchor, padding).Active = true;
Title.LeadingAnchor.ConstraintEqualTo(Icon.TrailingAnchor, padding).Active = true;
Title.TrailingAnchor.ConstraintEqualTo(ContentView.TrailingAnchor, -padding).Active = true;
Subtitle.TopAnchor.ConstraintEqualTo(Title.BottomAnchor).Active = true;
Subtitle.BottomAnchor.ConstraintEqualTo(ContentView.BottomAnchor, -padding).Active = true;
Subtitle.LeadingAnchor.ConstraintEqualTo(Icon.TrailingAnchor, padding).Active = true;
Subtitle.TrailingAnchor.ConstraintEqualTo(ContentView.TrailingAnchor, -padding).Active = true;
}
}