示例#1
0
        public static void AddAwesomeIcon(this UIButton self, AwesomeIcon icon, bool befor)
        {
            /* NSString *iconString = [NSString stringFromAwesomeIcon:icon];
             *  self.titleLabel.font = [UIFont fontWithName:@"FontAwesome"
             *                                         size:self.titleLabel.font.pointSize];
             *
             *  NSString *title = [NSString stringWithFormat:@"%@", iconString];
             *
             *  if(self.titleLabel.text) {
             *      if(before)
             *          title = [title stringByAppendingFormat:@" %@", self.titleLabel.text];
             *      else
             *          title = [NSString stringWithFormat:@"%@  %@", self.titleLabel.text, iconString];
             *  }
             *
             *  [self setTitle:title forState:UIControlStateNormal];
             */
            var iconString = StringFromAwesomeIcon(icon);

            self.TitleLabel.Font = UIFont.FromName("FontAwesome", self.TitleLabel.Font.PointSize);
            var title = String.Empty;

            if (befor)
            {
                title = self.TitleLabel.Text + " " + iconString;
            }
            else
            {
                title = iconString + " " + self.TitleLabel.Text;
            }
            self.SetTitle(title, UIControlState.Normal);
        }
示例#2
0
 public static string StringFromAwesomeIcon(AwesomeIcon icon)
 {
     if (awesomeStrings == null)
     {
         #region 定义字符
         awesomeStrings = new string[]
         {
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             "",
             ""
         };
         #endregion
     }
     return(awesomeStrings[(int)icon]);
 }