Пример #1
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            CustomizedAnnotationTableViewCell cell = tableView.DequeueReusableCell(CustomizedAnnotationTableViewCell.Key) as CustomizedAnnotationTableViewCell;

            if (cell == null)
            {
                cell = CustomizedAnnotationTableViewCell.Create();
            }
            cell.SelectionStyle = UITableViewCellSelectionStyle.None;

            if (AnnotationList.Count != 0)
            {
                var annotation = AnnotationList[indexPath.Row];

                cell.PublicationNameLabel.Text = annotation.BookTitle;
                DateTime date = annotation.UpdatedTime;

                cell.DateLabel.Text = date.ToString("dd MMM yyyy");
                string guidCardTitle = annotation.GuideCardName + ">" + annotation.TOCTitle;
                cell.GuidecardLabel.Text     = guidCardTitle;
                cell.HighlightTextLabel.Text = annotation.HighlightText;

                cell.NoteLabel.TextColor = ColorUtil.ConvertFromHexColorCode("#cccccc");
                if (annotation.NoteText != "")
                {
                    cell.NoteLabel.Text = annotation.NoteText;
                }
                else
                {
                    cell.NoteLabel.Text = "Add a note...";
                }
                getGuidList = annotation.CategoryTags;
                nfloat TagHeight = (tableView.Frame.Size.Width - 60 * 8) / 9;
                if (getGuidList.Count == 0)
                {
                    UIView emptyBtn = new UIView(new CGRect(0, 10, 10, 10));
                    emptyBtn.BackgroundColor    = UIColor.White;
                    emptyBtn.Layer.BorderColor  = ColorUtil.ConvertFromHexColorCode("#cccccc").CGColor;
                    emptyBtn.Layer.BorderWidth  = 1;
                    emptyBtn.Layer.CornerRadius = 10 / 2;

                    UILabel emptyLabel = new UILabel(new CGRect(18, 5, 120, 18));
                    emptyLabel.Text      = "Add a tag...";
                    emptyLabel.TextColor = ColorUtil.ConvertFromHexColorCode("#cccccc");
                    emptyLabel.Font      = UIFont.SystemFontOfSize(14);
                    cell.TagContainerView.AddSubview(emptyLabel);
                    cell.TagContainerView.AddSubview(emptyBtn);
                }
                else
                {
                    for (int i = 0; i < getGuidList.Count; i++)
                    {
                        AnnotationTag tag          = getGuidList[i];
                        UIColor       defaultColor = ColorUtil.ConvertFromHexColorCode(tag.Color);
                        TagsButton    btn          = new TagsButton();
                        btn.Frame                     = new CGRect((TagHeight + 60) * (i % 8), (i / 8) * 25, 60, 30);
                        btn.BackgroundColor           = UIColor.White;
                        btn.ColorView.BackgroundColor = defaultColor;
                        btn.ColorLabel.Text           = tag.Title;
                        btn.Layer.BorderColor         = UIColor.Clear.CGColor;
                        btn.Layer.BorderWidth         = 1;
                        btn.Layer.CornerRadius        = 10 / 2;
                        btn.ClipsToBounds             = true;
                        cell.TagContainerView.AddSubview(btn);
                    }
                }
            }

            cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
            return(cell);
        }