This commit is contained in:
2014-08-13 10:47:49 +08:00
parent a399153d3a
commit ca89d76411
6 changed files with 144 additions and 8 deletions
@@ -9,5 +9,18 @@
#import <UIKit/UIKit.h>
@interface FundListCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *infoLabel;
@property (weak, nonatomic) IBOutlet UILabel *profitLabel;
@property (weak, nonatomic) IBOutlet UILabel *totalLabel;
@property (weak, nonatomic) IBOutlet UILabel *numProfitLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UIImageView *typeImg;
@property (weak, nonatomic) IBOutlet DTAttributedLabel *buyTypeDtLabel;
@property (weak, nonatomic) IBOutlet DTAttributedLabel *lowestPriceDtLabel;
-(void)setBuyTypeWithString:(NSString*)htmlStr;
-(void)setLowestPriceWtihCount:(NSInteger)price;
@end
@@ -19,11 +19,34 @@
return self;
}
-(void)awakeFromNib
{
_buyTypeDtLabel.backgroundColor = [UIColor clearColor];
_lowestPriceDtLabel.backgroundColor = [UIColor clearColor];
[self setBuyTypeWithString:@"<font color=\"green\">随</font>买随卖"];
[self setLowestPriceWtihCount:1000];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(void)setBuyTypeWithString:(NSString *)htmlStr
{
NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentRight],DTDefaultTextAlignment, nil];
NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil];
_buyTypeDtLabel.attributedString = percentString;
}
-(void)setLowestPriceWtihCount:(NSInteger)price
{
NSString* htmlStr = [NSString stringWithFormat:@"<span style=\" color:break; \">%ld</span>元起",price];
NSData *data = [htmlStr dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary* optionsDic = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:kCTTextAlignmentRight],DTDefaultTextAlignment,[UIColor grayColor],DTDefaultTextColor, nil];
NSAttributedString *percentString = [[NSAttributedString alloc] initWithHTMLData:data options:optionsDic documentAttributes:nil];
_lowestPriceDtLabel.attributedString = percentString;
}
@end
+81 -2
View File
@@ -1,10 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4447" systemVersion="13A451" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="13E28" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3671"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3746"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="QCf-WQ-E2P" customClass="FundListCell">
<rect key="frame" x="0.0" y="0.0" width="320" height="108"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="QCf-WQ-E2P" id="tWO-H0-dwT">
<rect key="frame" x="0.0" y="0.0" width="320" height="107"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="我有五个字" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jTX-Fg-izQ">
<rect key="frame" x="10" y="14" width="140" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="小名字" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iSf-Cf-gGc">
<rect key="frame" x="10" y="43" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.25115593110000001" green="0.25115593110000001" blue="0.25115593110000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Ly-0U-oSK">
<rect key="frame" x="10" y="65" width="42" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.94664779970000001" green="0.21506300749999999" blue="0.1431705727" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="已经跑了30000米" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="O3F-FR-wcE">
<rect key="frame" x="143" y="13" width="120" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.25115593110000001" green="0.25115593110000001" blue="0.25115593110000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="万分收益" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vsv-fO-QlW">
<rect key="frame" x="143" y="43" width="90" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.25115593110000001" green="0.25115593110000001" blue="0.25115593110000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="icb-Rm-6zW">
<rect key="frame" x="143" y="65" width="90" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="fund_cell_label_bg_blue.png" translatesAutoresizingMaskIntoConstraints="NO" id="0hb-Ff-rGB">
<rect key="frame" x="283" y="14" width="30" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="D4z-2i-gXI" customClass="DTAttributedLabel">
<rect key="frame" x="238" y="47" width="67" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YEu-dt-BBV" customClass="DTAttributedLabel">
<rect key="frame" x="238" y="69" width="67" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</subviews>
</tableViewCellContentView>
<connections>
<outlet property="buyTypeDtLabel" destination="D4z-2i-gXI" id="g1r-cm-jQv"/>
<outlet property="infoLabel" destination="iSf-Cf-gGc" id="Ljq-tg-dGT"/>
<outlet property="lowestPriceDtLabel" destination="YEu-dt-BBV" id="Hc3-Q9-zG8"/>
<outlet property="nameLabel" destination="jTX-Fg-izQ" id="zZx-1E-bo3"/>
<outlet property="numProfitLabel" destination="vsv-fO-QlW" id="ztv-gd-QQI"/>
<outlet property="priceLabel" destination="icb-Rm-6zW" id="loT-Td-r0i"/>
<outlet property="profitLabel" destination="4Ly-0U-oSK" id="5oL-KW-9GM"/>
<outlet property="totalLabel" destination="O3F-FR-wcE" id="HdC-Ik-vzk"/>
<outlet property="typeImg" destination="0hb-Ff-rGB" id="XI5-40-QzE"/>
</connections>
</tableViewCell>
</objects>
<resources>
<image name="fund_cell_label_bg_blue.png" width="38" height="40"/>
</resources>
</document>
@@ -7,7 +7,7 @@
//
#import "FundListViewController.h"
#import "TriangleView.h"
#import "FundListCell.h"
@interface FundListViewController ()
@end
@@ -27,10 +27,32 @@
{
[super viewDidLoad];
// Do any additional setup after loading the view.
TriangleView* view = [[TriangleView alloc] initWithFrame:CGRectMake(20, 100, 200, 200)];
[self.view addSubview:view];
}
#pragma mark UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat height = 108.0;
return height;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *loanListCell = @"LoanListCell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:loanListCell];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:loanListCell];
NSArray *LoanListCellObjects = [[NSBundle mainBundle] loadNibNamed:@"FundListCell" owner:self options:nil];
cell = [LoanListCellObjects objectAtIndex:0];
}
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
@@ -28,7 +28,6 @@
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[_tableView setSectionIndexBackgroundColor:[UIColor blackColor]];
}
#pragma mark UITableViewDelegate
@@ -55,7 +54,7 @@
}
[(LoanListCell*)cell setPercent:40];
NSString* htmlStr = @"<span style=\"font-size:12px;text-align:center; color:green; \">限</span>12个月";
NSString* htmlStr = @"<span style=\"text-align:center; color:green;\">限</span>12个月";
[(LoanListCell*)cell setTimeWithString:htmlStr];
return cell;
}