This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathItemsViewCell.cs
48 lines (40 loc) · 1.66 KB
/
ItemsViewCell.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
using System;
using CoreGraphics;
using Foundation;
using UIKit;
namespace Xamarin.Forms.Platform.iOS
{
public abstract class ItemsViewCell : UICollectionViewCell
{
[Export("initWithFrame:")]
[Internals.Preserve(Conditional = true)]
protected ItemsViewCell(CGRect frame) : base(frame)
{
ContentView.BackgroundColor = UIColor.Clear;
var selectedBackgroundView = new UIView
{
BackgroundColor = ColorExtensions.Gray
};
SelectedBackgroundView = selectedBackgroundView;
}
protected void InitializeContentConstraints(UIView nativeView)
{
ContentView.TranslatesAutoresizingMaskIntoConstraints = false;
nativeView.TranslatesAutoresizingMaskIntoConstraints = false;
ContentView.AddSubview(nativeView);
// We want the cell to be the same size as the ContentView
ContentView.TopAnchor.ConstraintEqualTo(TopAnchor).Active = true;
ContentView.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active = true;
ContentView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor).Active = true;
ContentView.TrailingAnchor.ConstraintEqualTo(TrailingAnchor).Active = true;
// And we want the ContentView to be the same size as the root renderer for the Forms element
ContentView.TopAnchor.ConstraintEqualTo(nativeView.TopAnchor).Active = true;
ContentView.BottomAnchor.ConstraintEqualTo(nativeView.BottomAnchor).Active = true;
ContentView.LeadingAnchor.ConstraintEqualTo(nativeView.LeadingAnchor).Active = true;
ContentView.TrailingAnchor.ConstraintEqualTo(nativeView.TrailingAnchor).Active = true;
}
public abstract void ConstrainTo(nfloat constant);
public abstract void ConstrainTo(CGSize constraint);
public abstract CGSize Measure();
}
}